2

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 1

5

I see three easy solutions for you:

  1. Remove the autoload entries for the AppKernel and AppCache class from the composer.json file.

  2. 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.

  3. Similar to 2.: Do not add namespaces but use different class names for the different kernels.

Sign up to request clarification or add additional context in comments.

5 Comments

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?
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.
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 26
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
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.