How to create custom config file?

+
0
-

Is nette able to have multiple config files per module?
I have created my own modules,
eg:
BlogModule/presenters/BlogPresenter.php
BlogModule/templates/default.latte

I would like to have a custom config file with extends the current config options.
eg:
BlogModule/config/config.neon

How can this be done with nette?

Kev

Marek Bartoš
Nette Blogger | 1165
+
+3
-

In app/Bootstrap.php

$configurator->addConfig(__DIR__ . '/BlogModule/config/config.neon');

Each added file has higher priority than previous

In neon

includes:
  - relative/path/to/config.neon

Main file has higher priority than included files, each included file has higher priority than previous included file

Last edited by Mabar (2020-07-05 12:10)

+
0
-

Mabar wrote:

In app/Bootstrap.php

$configurator->addConfig(__DIR__ . '/BlogModule/config/config.neon');

Each added file has higher priority than previous

In neon

includes:
  - relative/path/to/config.neon

Main file has higher priority than included files, each included file has higher priority than previous included file

Thanks Mabar..
Is it possible for config to search paths for a config file, based on the module name
eg:

<?php

  $config_path = 'app/'.$module_name.'/config/config.neon';

  if( file_exists( $config_path ) ){
    include $config_path;
  }
?>
Marek Bartoš
Nette Blogger | 1165
+
+2
-

I would add each of them manually, but you can use finder to find your config files.

Wongani
Member | 1
+
-1
-

Some system administrators prefer to store sensitive settings in files outside the project directory. This default site structure was chosen for its simplicity – one file per package and environment. But like any other feature, you can customize it to better suit your needs. You can choose one of them or even create your own way of organizing files.

Nopero
Member | 1
+
0
-

Thank you for sharing, seems like I would have to add all the files manualy. I will start doig it tonight when I get to my house in Jurmala here later on, hope it works and will not take me long

Last edited by Nopero (2022-02-07 21:32)