Search by

ngames / framework

nbraquart

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

Package info

github.com/ngamesfr/ngames-framework

pkg:composer/ngames/framework

Statistics

Installs: 2 093

Dependents: 0

Suggesters: 0

Stars: 0

0.9.4 2026-09-04 18:48 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. Inside an action, $this->input() gives typed access to the request: string(), int(), bool() read the JSON body, queryString(), queryInt(), queryPositiveInt(), queryBool(), hasQuery() read the query string, file() returns an upload. A missing or mistyped value yields the default. $this->json($data, $options, HttpStatus::NotFound) and Response::setStatusCode() accept the HttpStatus enum as well as an int.