dev-master
9999999-dev https://github.com/vbardales/MultipleAppKernelBundleAllow Symfony2 base to host multiple apps
The Requires
by Virginie BARDALES
app symfony2 multiple
Allow Symfony2 base to host multiple apps
Allow Symfony2 app to host multiple applications., (*1)
``` bash git clone git://github.com/vbardales/MultipleAppKernelBundle.git vendor/bundles/MultipleApp/KernelBundle, (*2)
Or using deps file
[AdmingeneratorGeneratorBundle] git=git://github.com/vbardales/MultipleAppKernelBundle.git target=/bundles/MultipleApp/KernelBundle version=origin/master, (*3)
Or using composer.json
"vbardales/multiple-app-kernel-bundle": "dev-master",
Register it in the `autoload.php` file: ``` php <?php // app/autoload.php $loader->registerNamespaces(array( 'MultipleApp' => __DIR__.'/../vendor/bundles', ));
Common files (config, Resources, ...) are located in /commons
folder. Apps files are located in each app folder., (*4)
You can rename your /app
folder to /commons
. console
and AppKernel.php
files are no more required in this folder., (*5)
/commons
must contain autoload.php
initially existing in old /app
folder and BaseKernel.php
, which should look like :, (*6)
``` php <?php, (*7)
use MultipleApp\KernelBundle\Kernel\Kernel;, (*8)
abstract class BaseKernel extends Kernel { public function registerCommonsBundles() { $bundles = array( // ..., (*9)
// Multiple App new MultipleApp\KernelBundle\MultipleAppKernelBundle(), ); // ... return $bundles; }
}, (*10)
# App Kernels Apps files are located in each app folder. Each app folder (like `/backend`) should contain : - `AppCache.php` - `console` where requires must be updated like this ``` php #!/usr/bin/env php <?php // ... require_once __DIR__.'/../commons/bootstrap.php.cache'; require_once __DIR__.'/AppKernel.php'; // ...
console
can be found in your old /app
folder., (*11)
AppKernel.php
which should look like :``` php <?php, (*12)
require_once DIR.'/../commons/BaseKernel.php';, (*13)
use Symfony\Component\Config\Loader\LoaderInterface;, (*14)
class AppKernel extends BaseKernel { public function registerAppBundles() { $bundles = array( // ... );, (*15)
// ... return $bundles; } public function registerContainerConfiguration(LoaderInterface $loader) { $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); }
}, (*16)
# Config files In project folders, common resources may be included like : ``` php - { resource: "../../commons/config/config.yml" }
``` php $this->get('multiapp.routing_generator') // generate($appName, $name, $parameters = array(), $absolute = false) ->generate('frontend', 'myroute', array('page' => $Page, '_locale' => 'fr'), true);, (*17)
For absolute url define in parameters.yml :
parameters: multiapp.frontend.base_url: http://example.com ```, (*18)
Allow Symfony2 base to host multiple apps
app symfony2 multiple