Hello folks!
While I was surfing through Sylius, most of our DependencyInjection\Sylius*Extension classes loading multiple files are doing it on the PHP side like:
// SyliusMoneyExtension.php
$loader->load('services.xml');
$loader->load('templating.xml');
$loader->load('twig.xml');
or
// SyliusCurrencyExtension.php
$configFiles = [
'services.xml',
'templating.xml',
'twig.xml',
];
foreach ($configFiles as $configFile) {
$loader->load($configFile);
}
They're all files that are always loaded no matter what happens, so I came up with an idea to include additional files in the main one (usually services.xml) using imports:
$loader->load('services.xml');
<imports>
<import resource="templating.xml" />
<import resource="twig.xml" />
</imports>
This approach will apply only to files statically included, the dynamic ones like database driver dependent configuration (#4721) or the ones included only in test environment will still be loaded in extension class.
What do you think? :camel: :dromedary_camel:
The last call before alpha release. Should we change our current services organisation?
Proposing the following structure:
Resources/config/services.xml for all different services that are always loadedResources/config/services/*.xml for grouping services, always imported by the Resources/config/services.xmlResources/config/services/integrations/*.xml for services definitions loaded dynamically (eg. translations / grid support in ResourceBundle)The current Resources/config/driver/*.xml (like Resources/config/driver/doctrine/orm.xml) should be moved to Resources/config/services/integrations/doctrine/orm.xml etc.
This way we lower the includes in *Extension.php file to:
Resources/config/services.xmlResources/config/services/integration/*.xmlWhat do you think?
Sounds very good to me.
Most helpful comment
The last call before alpha release. Should we change our current services organisation?
Proposing the following structure:
Resources/config/services.xmlfor all different services that are always loadedResources/config/services/*.xmlfor grouping services, always imported by theResources/config/services.xmlResources/config/services/integrations/*.xmlfor services definitions loaded dynamically (eg. translations / grid support in ResourceBundle)The current
Resources/config/driver/*.xml(likeResources/config/driver/doctrine/orm.xml) should be moved toResources/config/services/integrations/doctrine/orm.xmletc.This way we lower the includes in
*Extension.phpfile to:Resources/config/services.xmlResources/config/services/integration/*.xmlWhat do you think?