-
-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for includes to contain parts to be replaced #170
Comments
Variability in include path would make cache invalidation very hard. This is IMHO task for application to deal with it. In one of mine modular application I do: # simplified
$includes = glob('modules/*/config.neon');
file_put_contents('modules.neon', Neon::encode(['includes' => $includes], Neon::BLOCK); and in main NEON config: includes:
- modules.neon Btw. there is already variables concept in Nette DI (like |
I agree, that it's the application's task to define how to find the configuration files. Sadly with the current implementation the easy solution(like %tmpPath%) and other variables that could be replaced is not possible without copiing most of the loader class. Even extracting the preparation of $include into a method of it's own would make it easier to allow adjustments to paths according to a specific application's rules if adding the replacements to nette/di itself is not useful enough. |
Same issue here. |
Is solution to expand |
Bit of a bump, but in PHPStan, I have the config file (which is a neon file) that needs some placeholders resolving. See phpstan/phpstan#2020 for more information. |
While using phpstan extensions(with phpstan using nette's di and loader(@ ^2.4.7||^3.0 )) I noticed that configuring the includes across different environments and relative paths was next to impossible without manually replacing the paths each time. A reference to a specific path not related to the config file's position would have helped out here by prefixing a relative path with a path to the tool used instead of the parent file's directory.
This would allow the loader to be less dependant on always having an identical file system structure, making it easier to use.
The resulting code in
Nette\DI\Config\Loader::load()
could look similar to the following:With the initial call (optionally) passing along replacements, for example:
I'm willing to implement this feature properly if it's desired.
The text was updated successfully, but these errors were encountered: