dev-main / 1.0.x-dev 2022-07-09 16:18 UTC

This package is auto-updated.

Last update: 2024-04-11 14:32:04 UTC


README

logo-120.png

M-Gine Framework

Requirements

  • PHP >= 8.0

Installing via Composer

Create the composer.json file as follows:

{
    "require-dev": {
        "michaltaglewski/m-gine": "dev-main"
    }
}

Run the composer installer:

php composer.phar install

Then initiate your first project. See the M-gine commands section below.

M-Gine commands

Right after the composer installation is completed, you are able to use M-Gine commands tool.

Execute binary file located in the vendor directory, like following:

./vendor/bin/mgine help

This command should display something similar to:

$ ./vendor/bin/mgine help

M-Gine commands (0.0.1)

Available commands:
  create-project       Creates a new project. Usage: project-create [name]
  init-project         Initializes a new project in current directory. Usage: init-project
  create-controller    Creates a Controller. Usage: create-controller [name] [namespace]

Initiate a project:

$ ./vendor/bin/mgine init-project

Project Directory Structure

config/             framework configuration
controllers/        MVC controllers directory
public/             web public folder (includes index.php)
models/             MVC models directory
tests/              tests of the core framework code
views/              MVC views directory

Configuration

Configure your main web configuration file config/web.php:

<?php

return [
    'basePath' => dirname(__DIR__),
    'language' => 'en',
    'charset' => 'utf-8',
    'components' => [
        'urlManager' => require 'urlManager.php',
        'db' => require 'db.php'
    ]
];

Url Manager component

config/urlManager.php:

<?php

return [
    'class' => 'mgine\web\UrlManager',
    'defaultRoute' => 'home/index',
    'rules' => [
        /**
         * Add your URL rules here
         * '/' => 'home/index',
         * '/about' => 'home/about',
         * '/contact' => 'home/contact',
         */
    ]
];

Database connection

config/db.php:

<?php

return [
    'class' => 'mgine\db\MysqlConnection',
    'dsn' => 'mysql:host=localhost;dbname=my_db_name',
    'username' => 'my_db_user',
    'password' => 'my_db_user_password',
    'charset' => 'utf8',
];