Search code examples
performancebundlebenchmarkingsymfony

Symfony2 multiple kernel?


I have application which has core website, api and admin area. I wanted to know is it bad idea to have everything in one app or should I create different Symfony2 project or should I split them into different kernels?

I'm not sure if adding lots of bundles on same kernel will effect performance a lot or is just a little bit, which does not matter?

Following are options:

  1. keep everything on same kernel, it wont make much difference
  2. have multiple kernel for different part of application (api, admin and core website)
  3. create different Symfony2 project for admin area and api.
  4. or your wise words :)

Solution

  • You can define more "environments".

    For example :

    In AppKernel.php

    public function registerBundles()
        {
            $bundles = array(
                new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
                new Symfony\Bundle\SecurityBundle\SecurityBundle(),
                new Symfony\Bundle\TwigBundle\TwigBundle(),
                new Symfony\Bundle\MonologBundle\MonologBundle(),
                new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
                new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
                new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
                //new AppBundle\AppBundle()
            );
    
            if (in_array($this->getEnvironment(), array('api'), true)) {
                $bundles[] = new ApiBundle\ApiBundle();
                //-- Other bundle
            }
            //-- Other environments
    
    
            return $bundles;
       }
    }