Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

Latest commit

 

History

History
96 lines (70 loc) · 2.22 KB

README.md

File metadata and controls

96 lines (70 loc) · 2.22 KB

Symfony Multiple Kernels

Use Symfony with multiple kernel approach.

Multiple Kernels

Symfony Multiple Kernels approach allows you create many independent Kernels. Thanks do that you can control list of enabled bundles as you wish.

Introduction

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.

Configs, Sessions, Caches & Logs

These issues have been resolved by overriding AppKernel.php methods;

New directory structure

app

app/
├── .htaccess
├── AdminKernel.php
├── ApiKernel.php
├── AppCache.php
├── AppKernel.php
├── KernelFactory.php
├── Resources
│   └── views
├── autoload.php
└── config
    ├── admin
    └── api

cache

var/cache/
├── .gitkeep
├── admin
│   └── dev
└── api
    └── dev

sessions

var/sessions/
├── .gitkeep
├── admin
│   └── dev
└── api
    └── dev

logs

var/logs
├── .gitkeep
├── admin
│   ├── dev.log
│   └── prod.log
└── api
    ├── dev.log
    └── prod.log

Multiple parameters.yml

This issue has been resolved by adding custom parameters builder; And replacement in composer.json

Switch between Multiple App Kernels

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