sFire PHP Framework

Modules

sFire lets you define multiple modules. This way you can separate logic and code between multiple domains. In the routes.php you can define which URL needs to go to which module.

In this section we will handle:

  • Module structure
  • Example to retrieve the current module
  • A brief example for obtaining a module config

Module structure

Every module has its own directory in the "modules" directory containing the following directories:

config
controllers
helpers
models
    tbtable
    entity
    mapper
translations
validators
views

In the "config" directory you can find the "config.php" to configure a specific module.

Example to retrieve the current module

sFire lets you retrieve the current module by doing:

use sFire\Routing\Router;

$module = Router :: getRoute() -> getModule();

echo $module; //Ouput similar to: "App"

A brief example for obtaining a module config

Imagine that the code below is in the "config.php":

return [

    'database' => [

        'host'      => '127.0.0.1',
        'username'  => 'username',
        'password'  => 'password',
        'db'        => 'database',
    ]
];

To obtain this config, you first need to determine the current module and select the config:

use sFire\Routing\Router;
use sFire\Config\Config;

$module = Router :: getRoute() -> getModule();
$config = Config :: get([$module, 'database']);

print_r($config);