Le 13/08/2011 23:35, Oleg Stepura a écrit :
Hi everybody!

Since the very beginning of my working with early symfony 2.0 prereleases I was asking myself - why should I add 3 records into 3 different places when I add a bundle to make it work (autoloading rule, config.yml, AppKernel::registerBundles()). This makes it a little bit harder to add bundles into the system.

The possible improvement could be to only add 1 record to config.yml with 2 extra fields - the bundle class name and the path(s) for the autoloader (which should have special config key names).
The kernel need to know the bundles to be able to load the configuration, which is optional (a bundle may not need any special configuration) and is handled by the bundle code, not by the kernel.

Another solution could be searching for bundles in some custom directory (configurable) on cache warmup phase and load all found bundles with it's default configuration and allow for tweaking that configuration in application main config.yml (almost the same way as it is now). Editing the config.yml's bundle config options one could also completely disable the bundle so that it is ignored. But imagine how it could be easy to install bundles that don't require any customization. Or installing 3party bundles for intital testing - just copy (git clone) the bundle, clear the cache and you're done.

Since all configuration is compiled I think this could be achived by adding some custom methods to a compiled application container class or creating another generated class which is loaded by kernel and which fills the registered bundles array in kernel and somehow adjusts the used autoloader class.

For the last approach it would be required to let the Kernel know about the autoloader class being used (which must implement commom interface). For this the app/autoload.php file must be renamed and have the "AppLoader" class (for example). This class would simply inherit the Symfony\Component\ClassLoader\UniversalClassLoader or maybe a customized one with all the logic from autoload.php being moved into register() method of this AppLoader with parent::register() call in the end.

One thing I cannot answer yet is how to behave when bundle has some other vendor dependecies (think of AvalancheImagineBundle <https://github.com/avalanche123/AvalancheImagineBundle>). Any ideas are appreciated.

Currently I would like to know what people think of this approach. Maybe someone can point some key things that I missed which make all this impossible/hard to implement. And I would also like to know if this is a welcomed functionality inside Symfony itself.

Thanks!

Registering the autoloader according to some classes in the bundle cannot work. The autoloader need to be registered *before* using any class from the bundle as its goal is about letting PHP know where it can find the classes.

--
Christophe | Stof

--
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en

Reply via email to