Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/partikus/symfony-multiple-kernels
Repository presents Symfony project with multiple kernel approach.
https://github.com/partikus/symfony-multiple-kernels
kernel multiple multiple-kernels php symfony
Last synced: about 1 hour ago
JSON representation
Repository presents Symfony project with multiple kernel approach.
- Host: GitHub
- URL: https://github.com/partikus/symfony-multiple-kernels
- Owner: partikus
- Created: 2017-05-05T15:33:07.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-06T15:09:08.000Z (over 7 years ago)
- Last Synced: 2024-12-09T00:17:12.539Z (about 2 months ago)
- Topics: kernel, multiple, multiple-kernels, php, symfony
- Language: PHP
- Homepage: https://kruczek.it
- Size: 48.8 KB
- Stars: 0
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Symfony Multiple Kernels
========================Repository presents [Symfony](http://symfony.com/doc/current/index.html) project with multiple kernel approach.
## Multiple Kernels
Symfony [Multiple Kernels](http://symfony.com/doc/current/configuration/multiple_kernels.html) allows you create many independent Kernels. Thanks to that you can: manage the bundles you use and separate configuration for every kernel.
## IntroductionLet's assume your project has two parts:
- `api`
- `admin`And just only for `admin` version you need to use `Twig` which is useless for `api` part. To achieve this you have to create two instances of `AppKernel`:
- [`ApiKernel`](app/ApiKernel.php)
- [`AdminKernel`](app/AdminKernel.php)Those two classes extend from [`AppKernel`](app/AppKernel.php). This way you can get separate bundle list for each kernel.
## Configs, Sessions, Caches & LogsTo separate configuration, sessions, caches and logs you need overwrite `AppKernel.php` methods;
- [`getCacheDir`](app/AppKernel.php#L42)
- [`getLogDir`](app/AppKernel.php#L47)
- [`getKernelParameters`](app/AppKernel.php#L52)
- [`registerContainerConfiguration`](app/AppKernel.php#L62)
## 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
Separate parameters require [custom parameters builder](src/MultipleKernels/Composer/ScriptHandler.php),
and replacement in [composer.json](composer.json#L45).## 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`