Set config debug mode into neon config

2 years ago

Member | 27

Hello there,
I looking for easy and developer friendly set debug mode into NEON configure file, becose i use two different configure files. “config.neon” with product application settings and “config.local.neon” with confugre only for local development. Now i must change configuration of method $configurator->setDebugMode(true); inside boostrap.php on false. How convert this method function into NEON configure file?

Last edited by Sitole (2017-12-10 12:01)

about a year ago

Nette Core | 914


well you can't because Nette setup debug mode before neon files are loaded (…tor.php.html#…).

I think you can achieve it other ways.

1. Detect by file

Let's choose some file, for example root/app/.debug with no content and update your bootstrap.php.

if (file_exists(__DIR__ . '/.debug')) {

You will be absolute free of change of bootstrap.php.

2. Detect by file content

You can extend Nette\Configurator and add method setDebugModeBy(file).

Inside your new Configurator.

public function setDebugModeBy($file)
    $loader = new Nette\DI\Config\Loader();
    $content = $loader->load($file);

    if (isset($content['mode'])) {

It's more powerful, you can override more parameters/settings.

3. Detect by ENV

if (getenv('NETTE_DEBUG', true)) == '1') {

Be aware of 3rd party change.

Last edited by Felix (2017-12-17 21:58)