Use Symfony with multiple kernel approach.
Symfony Multiple Kernels approach allows you create many independent Kernels. Thanks do that you can control list of enabled bundles as you wish.
Let's assume our project has two parts:
api
admin
And just only for admin
version you need to use Twig
. To solve this issue we have to create two instances of AppKernel
:
Those two classes extend from AppKernel
. Thanks to that per each kernel you could have two indepentent list of bundles.
These issues have been resolved by overriding AppKernel.php
methods;
app/
├── .htaccess
├── AdminKernel.php
├── ApiKernel.php
├── AppCache.php
├── AppKernel.php
├── KernelFactory.php
├── Resources
│ └── views
├── autoload.php
└── config
├── admin
└── api
var/cache/
├── .gitkeep
├── admin
│ └── dev
└── api
└── dev
var/sessions/
├── .gitkeep
├── admin
│ └── dev
└── api
└── dev
var/logs
├── .gitkeep
├── admin
│ ├── dev.log
│ └── prod.log
└── api
├── dev.log
└── prod.log
This issue has been resolved by adding custom parameters builder; And replacement in composer.json
This action can be handle by exporting APP_NAME
env like SYMFONY_ENV
or by adding -a admin
or --app-name=admin
command's options. e.g. bin/console --app-name=admin