Example #1
0
 protected function loadCompiledAndInitSth()
 {
     if (file_exists($this->compiledPath)) {
         require $this->compiledPath;
     }
     // removed from Illuminate\Foundation\Http\Kernel::handle
     \Illuminate\Http\Request::enableHttpMethodParameterOverride();
 }
Example #2
0
 public function onWorkerStart($serv, $worker_id)
 {
     //创建laravel内核(把该逻辑放在此处,确保所有worker创建前父进程副本与laravel无关,令laravel具备热部署特性)
     require __DIR__ . '/../bootstrap/autoload.php';
     $app = (require __DIR__ . '/../bootstrap/app.php');
     $this->laravel_kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);
     //开启“方法欺骗”特性,与laravel5.1 LTS保持一致
     Illuminate\Http\Request::enableHttpMethodParameterOverride();
 }
Example #3
0
 /**
  * Handle an incoming HTTP request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function handle($request)
 {
     try {
         $request->enableHttpMethodParameterOverride();
         $response = $this->sendRequestThroughRouter($request);
     } catch (Exception $e) {
         $this->reportException($e);
         $response = $this->renderException($request, $e);
     }
     $this->app['events']->fire('kernel.handled', [$request, $response]);
     return $response;
 }
Example #4
0
 public static function bootstrap($errorCallbacks)
 {
     // Only bootstrap once.
     if (static::$bootstrapped) {
         return;
     }
     // Load helper functions.
     require_once __DIR__ . '/../../../illuminate/support/Illuminate/Support/helpers.php';
     // Directories.
     $basePath = str_finish(realpath(__DIR__ . '/..'), '/');
     $controllersDirectory = $basePath . 'Controllers';
     $modelsDirectory = $basePath . 'Models';
     // Register the autoloader and add directories.
     ClassLoader::register();
     ClassLoader::addDirectories(array($controllersDirectory, $modelsDirectory));
     // Instantiate the container.
     $app = new Container();
     static::$container = $app;
     // Tell facade about the application instance.
     Facade::setFacadeApplication($app);
     // Register application instance with container
     $app['app'] = $app;
     // Set environment.
     $app['env'] = 'production';
     // Enable HTTP Method Override.
     Request::enableHttpMethodParameterOverride();
     // Create the request.
     $app['request'] = Request::createFromGlobals();
     // Register services.
     with(new EventServiceProvider($app))->register();
     with(new RoutingServiceProvider($app))->register();
     // Register aliases.
     foreach (static::$aliases as $alias => $class) {
         class_alias($class, $alias);
     }
     // Load the routes file if it exists.
     if (file_exists($basePath . 'routes.php')) {
         require_once $basePath . 'routes.php';
     }
     // Dispatch on shutdown.
     register_shutdown_function('Seytar\\Routing\\Router::dispatch', $errorCallbacks);
     // Mark bootstrapped.
     static::$bootstrapped = true;
 }
Example #5
0
 /**
  * Creates the application.
  *
  * Needs to be implemented by subclasses.
  *
  * @return \Symfony\Component\HttpKernel\HttpKernelInterface
  */
 public function createApplication()
 {
     $app = new Application();
     $app->detectEnvironment(array('local' => array('your-machine-name')));
     $app->bindInstallPaths($this->getApplicationPaths());
     $app['env'] = 'testing';
     $app->instance('app', $app);
     Facade::clearResolvedInstances();
     Facade::setFacadeApplication($app);
     $app->registerCoreContainerAliases();
     with($envVariables = new EnvironmentVariables($app->getEnvironmentVariablesLoader()))->load($app['env']);
     $app->instance('config', $config = new Repository($app->getConfigLoader(), $app['env']));
     $app->startExceptionHandling();
     date_default_timezone_set($this->getApplicationTimezone());
     $aliases = array_merge($this->getApplicationAliases(), $this->getPackageAliases());
     AliasLoader::getInstance($aliases)->register();
     Request::enableHttpMethodParameterOverride();
     $providers = array_merge($this->getApplicationProviders(), $this->getPackageProviders());
     $app->getProviderRepository()->load($app, $providers);
     $this->registerBootedCallback($app);
     return $app;
 }
Example #6
0
 /**
  * Enables support for the _method request parameter to determine the intended HTTP method.
  * 
  * Be warned that enabling this feature might lead to CSRF issues in your code.
  * Check that you are using CSRF tokens when required.
  * If the HTTP method parameter override is enabled, an html-form with method "POST" can be altered
  * and used to send a "PUT" or "DELETE" request via the _method request parameter.
  * If these methods are not protected against CSRF, this presents a possible vulnerability.
  * 
  * The HTTP method can only be overridden when the real HTTP method is POST.
  *
  * @static 
  */
 public static function enableHttpMethodParameterOverride()
 {
     //Method inherited from \Symfony\Component\HttpFoundation\Request
     return \Illuminate\Http\Request::enableHttpMethodParameterOverride();
 }
Example #7
0
| is bound in the application since it contains the alias definitions.
|
*/
$aliases = $config['aliases'];
AliasLoader::getInstance($aliases)->register();
/*
|--------------------------------------------------------------------------
| Enable HTTP Method Override
|--------------------------------------------------------------------------
|
| Next we will tell the request class to allow HTTP method overriding
| since we use this to simulate PUT and DELETE requests from forms
| as they are not currently supported by plain HTML form setups.
|
*/
Request::enableHttpMethodParameterOverride();
/*
|--------------------------------------------------------------------------
| Register The Core Service Providers
|--------------------------------------------------------------------------
|
| The Illuminate core service providers register all of the core pieces
| of the Illuminate framework including session, caching, encryption
| and more. It's simply a convenient wrapper for the registration.
|
*/
$providers = $config['providers'];
$app->getProviderRepository()->load($app, $providers);
/*
|--------------------------------------------------------------------------
| Register Booted Start Files
Example #8
0
 /**
  * Handle an incoming HTTP request.
  *
  * @param  \Illuminate\Http\Request $request
  *
  * @return \Illuminate\Http\Response
  */
 public function handle($request)
 {
     $request->enableHttpMethodParameterOverride();
     $this->sendRequestThroughRouter($request);
     return $this;
 }