AppKernel.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. use Symfony\Component\HttpKernel\Kernel;
  3. use Symfony\Component\Config\Loader\LoaderInterface;
  4. use Symfony\Component\ClassLoader\DebugUniversalClassLoader;
  5. use Symfony\Component\HttpKernel\Debug\ErrorHandler;
  6. use Symfony\Component\HttpKernel\Debug\ExceptionHandler;
  7. class AppKernel extends Kernel
  8. {
  9. public function registerBundles()
  10. {
  11. $bundles = array(
  12. new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
  13. new Symfony\Bundle\SecurityBundle\SecurityBundle(),
  14. new Symfony\Bundle\TwigBundle\TwigBundle(),
  15. new Symfony\Bundle\MonologBundle\MonologBundle(),
  16. new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
  17. new Symfony\Bundle\DoctrineBundle\DoctrineBundle(),
  18. new Symfony\Bundle\AsseticBundle\AsseticBundle(),
  19. new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
  20. new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),
  21. new Packagist\WebBundle\PackagistWebBundle(),
  22. );
  23. if (in_array($this->getEnvironment(), array('dev', 'test'))) {
  24. $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
  25. }
  26. return $bundles;
  27. }
  28. public function init()
  29. {
  30. if ($this->debug) {
  31. ini_set('display_errors', 1);
  32. error_reporting(-1);
  33. DebugUniversalClassLoader::enable();
  34. ErrorHandler::register();
  35. if ('cli' !== php_sapi_name()) {
  36. ExceptionHandler::register();
  37. }
  38. } else {
  39. ini_set('display_errors', 0);
  40. }
  41. }
  42. public function registerContainerConfiguration(LoaderInterface $loader)
  43. {
  44. $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
  45. }
  46. }