ngames/framework

The NGames Framework is a simple PHP framework developped for the websites https://www.worldwar.fr and https://www.guide-tnt.fr

0.3.5 2021-10-22 18:23 UTC

This package is auto-updated.

Last update: 2024-04-22 23:46:31 UTC


README

Build Status License Last release

Coverage

Installation

Use composer to install the application: composer require ngames/framework. Or you can update the composer.json file by adding the following line in the require object:

{
    "require": {
        "ngames/framework": "~0.3"
    }
}

Usage

Configuration file

You need to write a configuration file using INI format. Typically, this file is called config.ini and is located in the config folder at the root of the project. Here is an example with all supported configuration keys:

# Database configuration
database.host       = "127.0.0.1"
database.username   = "db_user"
database.password   = "db_password"
database.name       = "db_name"

# Log configuration (destination must be a file), the level is the minimum level for logging messages
log.destination     = "./logs/application.log"
log.level           = "debug"

# Whether the debug mode is enabled or not (default is false)
debug               = "true"

Application initialization

In a public folder in the root of the project, create a file named index.php with the following content:

<?php
defined("ROOT_DIR") || define ("ROOT_DIR", dirname(__DIR__));
chdir(ROOT_DIR);

// Initialize and run the application
require_once ROOT_DIR . '/vendor/autoload.php';
\Ngames\Framework\Application::initialize(ROOT_DIR . '/config/config.ini')->run();

That's all you need to startup the application.

Controllers

Controllers are located in a src folder in the root of the project. They are grouped by folders representing the modules. The default module is Application.