I run with 3 sites with the same app on Symfony2, all of these sites have a custom AppKernel.php file. I'm now upgrading to Symfony3 and it seem that the composer.json including by default the file "app/AppKernel.php" and "app/AppCache.php". I would like to provide app/AppKernel.php for site A and apps/siteB/app/AppKernel.php for site B. How can i set a custom AppKernel location?
1 Answer
I see three easy solutions for you:
Remove the autoload entries for the
AppKernelandAppCacheclass from thecomposer.jsonfile.Use different namespaces for each kernel class, change the autoload configuration to be able to load all of them and use the right namespace when creating and booting the kernel.
Similar to 2.: Do not add namespaces but use different class names for the different kernels.
5 Comments
Cerad
Given that the AppKernel class is not autoloaded and is not namespaced, how exactly is your approach supposed to work? Perhaps you could post a composer.json example?
xabbuh
Both the
AppKernel and AppCache class are autoloaded in recent versions of the Symfony Standard Edition (see this change), but you can do similar changes in your own project's composer.json file.Siol
If i remove
AppKernel and AppCache from composer.json when i update composer i have this error Fatal error: Class 'AppKernel' not found in ***\bin\console on line 26Siol
If i add require AppKernel.php on the console file and on app.php its working ;). But still wonder if this is the proper solution
xabbuh
As mentioned you can use one of the other two approaches too to solve your problem and I would probably go for one of them as they don't require you to load the classes yourself.