Latest release: v0.3.1

Bootstrap

Content

ExtraConfigurator

The ExtraConfigurator extends Configurator and adds a few methods for better usage in containers (Docker).

  • setFileDebugMode($fileName = NULL)
  • setEnvDebugMode()
  • addEnvParameters()

Debug mode

We added two methods to help you detect the debug mode. You can either manage the debug mode via NETTE_DEBUG environmental variable and detect it this way:

$configurator = new ExtraConfigurator();
$configurator->setEnvDebugMode();
1
2

or via a file. If no file is supplied as a parameter, it looks for .debug file in the root directory. The sole existence of the file with no content will set the debug mode to TRUE.

$configurator = new ExtraConfigurator();
$configurator->setFileDebugMode(__DIR__ . '/../.debug');
1
2

Valid values for the ENV variable NETTE_DEBUG and the file are:

  • true
  • 1
  • false
  • 0
  • 10.0.0.10
  • cookie@10.0.0.10

Environment variables

You can now setup your config parameters over environment variables.

Environment variable must follow this pattern: NETTE__{NAME}, NETTE__{NAME}__{NAME2}.

export NETTE__DATABASE__USER=test
export NETTE__DATABASE__HOST=localhost
1
2

Just create your configurator object.

use Contributte\Bootstrap\ExtraConfigurator;

$configurator = new ExtraConfigurator();
$configurator->addEnvParameters();
1
2
3
4

That's all.


Helpers

You can also use these static methods for parsing ENV variables and setting the debug mode from the ENV variable.

$configurator->setDebugMode(ExtraConfigurator::parseEnvDebugMode());
$configurator->addParameters(ExtraConfigurator::parseEnvironmentParameters());
$configurator->addParameters(ExtraConfigurator::parseAllEnvironmentParameters());
1
2
3

PluggableConfigurator

There's a need to organize bulk of codes together, we call them plugins. Official Nette\Configurator does not support any type of plugin, so PluggableConfigurator was created.

use Contributte\Bootstrap\PluggableConfigurator;

$pluggable = new PluggableConfigurator();

$pluggable->addPlugin(new MyBeforeContainerIsLoadedPlugin());
$pluggable->addPlugin(new SpecialOnlyInDebugModePlugin());
1
2
3
4
5
6

You can easilly add a new plugin via addPlugin($plugin) method.

There are some types of plugin.

Plugin Triggers Arguments Mode
IConfigurationPlugin before createContainer Configurator ALL
IContainerPlugin after createContainer Configurator, Container ALL
IDebugContainerPlugin after createContainer Configurator, Container DEBUG
ICompilerPlugin during generateContainer Configurator, Compiler ALL
IDebugCompilerPlugin during generateContainer Configurator, Compiler DEBUG