Loader (Bootstrap.php)
Class Bootstrap app/Console/Bootstrap.php
performs the following methods:
- Creating an application
__construct()
// Create app
$this->app = new Silex\Application();
- Configuration application
_iniConfig
- Initialization providers
_iniProviders
- Initialization services
_iniServices
и_extendServices
- Initialization commands
_iniCommands
- Initialization application
_iniApplication
Configuration application
The configuration is defined by app/Resources/Config/parameters.yml
file.
There are set values of the main parameters of your configuration,
which can be used in your other configurations.
Parameter values can be accessed through $app['config']['parameters']
.
The values of the basic parameters:
- Time zone (timezone)
- Language localization (locale)
- The sign debug (debug)
- Environment (environment)
- Directory of data storage for console application (data_dir)
- Host address for local testing (url_test)
- Database Options (db.driver, db.path, db.name, db.models.path, db.models.namespace, db.connection.production, db.connection.development, db.connection.test)
- Email settings (mail.host, mail.port, mail.username, mail.password)
Initialization providers
Providers are installed as shown below.
...
// Register the service providers
foreach ($app['config']['service_providers'] as $serviceProviderConfig) {
$app->register(
new $serviceProviderConfig['class'](
(!isset($serviceProviderConfig['construct_parameters'])) ?
null : $serviceProviderConfig['construct_parameters']
), (isset($serviceProviderConfig['parameters']) &&
null !== $serviceProviderConfig['parameters']) ?
$serviceProviderConfig['parameters'] : array()
);
}
...
Initialization services
With class MyService app/Services/MyService.php
installed services app/Services/My
.
This includes the following services:
- Working with arrays (
ArrayBox.php
) - Working with XML (
CrXml.php
) - Working with HTTP (
Http.php
) - Work with parameters (
ParamBox.php
) - Working with strings (
String.php
) - Common Functions (
System.php
)
With class Zf2Service app/Services/Zf2Service.php
installed services from
Zend Framework 2 vendor/zendframework
.
This includes the following services:
With metod _extendServices
of class Bootstrap loader app/Console/Bootstrap.php
extends the functionality of some services such as: $app['translator']
, $app['twig']
.
Initialization commands
Commands are set as shown below.
...
foreach ($app['config']['commands'] as $name => $commandConfig) {
$classCommand = $commandConfig['class'];
if (isset($commandConfig['configure'])) {
$commandName = $commandConfig['configure']['name'];
$commandInstance = new $classCommand($commandName);
if (property_exists($commandInstance, 'app')) {
$commandInstance->app = $app;
}
if (property_exists($commandInstance, 'config_name')) {
$commandInstance->config_name = $name;
}
$commandInstance->setCommandConfig();
} else {
$commandInstance = new $classCommand();
if (property_exists($commandInstance, 'app')) {
$commandInstance->app = $app;
}
}
$app['console']->add($commandInstance);
}
...
Initialization application
In this method, you create a directorys necessary for the functioning of the console application. This is the first time the console is started.
...
// Create application paths
$app['my']->get('config')->createAppPaths();
...