AppKernel.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 FOS\UserBundle\FOSUserBundle(),
  22. new Packagist\WebBundle\PackagistWebBundle(),
  23. );
  24. if (in_array($this->getEnvironment(), array('dev', 'test'))) {
  25. $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
  26. }
  27. return $bundles;
  28. }
  29. public function init()
  30. {
  31. if ($this->debug) {
  32. ini_set('display_errors', 1);
  33. error_reporting(-1);
  34. DebugUniversalClassLoader::enable();
  35. ErrorHandler::register();
  36. if ('cli' !== php_sapi_name()) {
  37. ExceptionHandler::register();
  38. }
  39. } else {
  40. ini_set('display_errors', 0);
  41. }
  42. }
  43. public function registerContainerConfiguration(LoaderInterface $loader)
  44. {
  45. $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
  46. }
  47. }