Here is my config file for services:
Now, I'd like to have Backend services only loaded when I am in the Backend
The main reason is that I want to have the ability to create plugins for my app and extend the app's functionality and should those plugins have their own services, it would be nice if I didn't have to write each one in the main config file.
Maybe there is another way?
Last edited by jeremy (2022-01-16 17:43)
- Marek Bartoš
- Nette Blogger | 651
Instance of service is not created unless you request that service from DI (via constructor, inject method, …).
Only downside is for each service is generated one method in compiled DI container. But you should not worry about that, compiled DIC can have tens of thousands lines of code and it will not affect performance even slightly.
To split services into multiple files, use include:
includes: - Backend/wiring.neon - Frontend/wiring.neon
If you plan to have optional plugins (e.g. in vendor directory), bootstrap is the way to go:
$configurator->addConfig(__DIR__ . '/../vendor/example/package/src/wiring.neon');
Last edited by Marek Bartoš (2022-01-16 18:04)