Created
April 3, 2014 22:24
-
-
Save pulse00/9964098 to your computer and use it in GitHub Desktop.
Symfony2 multiple kernels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frontend specific config in /frontend/config/config.yml | |
imports: | |
- { resource: security.yml } | |
... | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\HttpKernel\Kernel; | |
use Symfony\Component\Config\Loader\LoaderInterface; | |
// base kernel in app/AppKernel.php | |
class AppKernel extends Kernel | |
{ | |
public function registerBundles() | |
{ | |
$bundles = array( | |
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), | |
// ... | |
); | |
return $bundles; | |
} | |
public function registerContainerConfiguration(LoaderInterface $loader) | |
{ | |
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# common configuration in app/config/config.yml | |
imports: | |
- { resource: redis.yml } | |
- { resource: parameters.yml } | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require __DIR__ .'/../app/AppKernel.php'; | |
use Symfony\Component\Config\Loader\LoaderInterface; | |
// frontend specific kernel in frontend/FrontendKernel.php | |
class FrontendKernel extends \AppKernel | |
{ | |
/** | |
* {@inheritDoc} | |
*/ | |
public function registerBundles() | |
{ | |
$bundles = parent::registerBundles(); | |
$bundles[] = new FOS\JsRoutingBundle\FOSJsRoutingBundle(); | |
return $bundles; | |
} | |
public function registerContainerConfiguration(LoaderInterface $loader) | |
{ | |
// load parent config | |
parent::registerContainerConfiguration($loader); | |
// load child-kernel config | |
$loader->load(__DIR__.'/config_'.$this->getEnvironment().'.yml'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment