- PHP >= 8.0
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.
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
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
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'
]
];
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',
*/
]
];
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',
];