web/app.php line 52

Open in your IDE?
  1. <?php
  2. use Symfony\Component\HttpFoundation\Request;
  3. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  4. use Symfony\Component\HttpKernel\HttpKernelInterface;
  5. use Symfony\Component\HttpFoundation\Response;
  6. // phpinfo();die;
  7. $environment 'dev'//'prod'|'dev'
  8. $dev = ($environment === 'dev');
  9. $path $_SERVER['REQUEST_URI'];
  10. $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';
  11. $_SERVER['HTTP_X_FORWARDED_PORT'] = '443';
  12. try {
  13.     $m = new \Memcached();
  14.     $m->addServer('localhost'11211);
  15.     if (!$dev && $page $m->get($path)) {
  16.         echo $page;
  17.         die;
  18.     }
  19. } catch (Exception $e) {
  20.     if ($dev) {
  21.         var_dump($e);
  22.         die;
  23.     }
  24. } finally {
  25.     $loader = require_once __DIR__ '/../app/autoload.php';
  26. // Enable APC for autoloading to improve performance.
  27. // You should change the ApcClassLoader first argument to a unique prefix
  28. // in order to prevent cache key conflicts with other applications
  29. // also using APC.
  30.     /*
  31.     $apcLoader = new ApcClassLoader(sha1(__FILE__), $loader);
  32.     $loader->unregister();
  33.     $apcLoader->register(true);
  34.     */
  35.     require_once __DIR__ '/../app/AppKernel.php';
  36. //require_once __DIR__.'/../app/AppCache.php';
  37.     $kernel = new AppKernel($environment$dev);
  38. //$kernel = new AppCache($kernel);
  39. // When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter
  40. //Request::enableHttpMethodParameterOverride();
  41.     $request Request::createFromGlobals();
  42.     try {
  43.         $response $kernel->handle($requestHttpKernelInterface::MASTER_REQUESTtrue); //$dev
  44.     } catch (Exception $e) {
  45.         if ($dev) {
  46.             if (property_exists($e'xdebug_message')) {
  47.                 $message $e->xdebug_message;
  48.             } else {
  49.                 $message '<tr><td><pre>' var_export($etrue) . '</pre></td></tr>';
  50.             }
  51.             echo <<<MES
  52. <!DOCTYPE html>
  53. <html class="no-js" lang="en">
  54.     <head>
  55.      <meta charset="UTF-8">
  56.      <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  57.      <title>Error!</title>
  58.     </head>
  59. <body>
  60. <table>
  61. {$message}
  62. </table>
  63. </body>
  64. </html>
  65. MES;
  66.         } else {
  67. /*
  68. if (method_exists($kernel = $event->getKernel(), 'terminateWithException')) {
  69.                     $request = $event->getRequest();
  70.                     $hasRun = &$this->hasTerminatedWithException;
  71.                     $this->exceptionHandler = function (\Exception $e) use ($kernel, $request, &$hasRun) {
  72.                         if ($hasRun) {
  73.                             throw $e;
  74.                         }
  75.                         $hasRun = true;
  76.                         $kernel->terminateWithException($e, $request);
  77.                     };
  78.                 }
  79.  */
  80.     //        $kernel->terminate($request,new Response());
  81.         }
  82.     }
  83.         // $headers = $response->headers;
  84.         //$response->sendHeaders();
  85.         /*
  86.           if ($request->isXmlHttpRequest()) {
  87.               $headers = $request->headers;
  88.           }
  89.           if ($response->isRedirect() || $response->isRedirection()) {
  90.               $response->setStatusCode(302);
  91.               $headers = $response->headers;
  92.               $kernel->terminate($request, $response);
  93.           }
  94.           else { */
  95.         //$host = $this->getContainer()->get('router')->getContext()->getHost();
  96.         if(!empty($response)) {
  97.             $response->send();
  98.         } else {
  99.             $response = new Response();
  100.         }
  101.             $kernel->terminate($request$response);
  102.         // }
  103. }