2017 © Pedro Peláez
 

symfony-bundle multiple-app-kernel-bundle

Allow Symfony2 base to host multiple apps

image

vbardales/multiple-app-kernel-bundle

Allow Symfony2 base to host multiple apps

  • Thursday, April 6, 2017
  • by vbardales
  • Repository
  • 6 Watchers
  • 19 Stars
  • 2,943 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 8 Forks
  • 0 Open issues
  • 1 Versions
  • 2 % Grown

The README.md

MultipleAppKernelBundle

Allow Symfony2 app to host multiple applications., (*1)

Installation

``` 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', ));

New structure

Common files (config, Resources, ...) are located in /commons folder. Apps files are located in each app folder., (*4)

Commons

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" }

Generate multi apps routes

``` 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)

The Versions

06/04 2017

dev-master

9999999-dev https://github.com/vbardales/MultipleAppKernelBundle

Allow Symfony2 base to host multiple apps

  Sources   Download

The Requires

 

by Virginie BARDALES

app symfony2 multiple