You are here

protected function ServerCommand::boot in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Command/ServerCommand.php \Drupal\Core\Command\ServerCommand::boot()
  2. 10 core/lib/Drupal/Core/Command/ServerCommand.php \Drupal\Core\Command\ServerCommand::boot()

Boots up a Drupal environment.

Return value

\Drupal\Core\DrupalKernelInterface The Drupal kernel.

Throws

\Exception Exception thrown if kernel does not boot.

1 call to ServerCommand::boot()
ServerCommand::execute in core/lib/Drupal/Core/Command/ServerCommand.php
Executes the current command.

File

core/lib/Drupal/Core/Command/ServerCommand.php, line 92

Class

ServerCommand
Runs the PHP webserver for a Drupal site for local testing/development.

Namespace

Drupal\Core\Command

Code

protected function boot() {
  $kernel = new DrupalKernel('prod', $this->classLoader, FALSE);
  $kernel::bootEnvironment();
  $kernel
    ->setSitePath($this
    ->getSitePath());
  Settings::initialize($kernel
    ->getAppRoot(), $kernel
    ->getSitePath(), $this->classLoader);
  $kernel
    ->boot();

  // Some services require a request to work. For example, CommentManager.
  // This is needed as generating the URL fires up entity load hooks.
  $kernel
    ->getContainer()
    ->get('request_stack')
    ->push(Request::createFromGlobals());
  return $kernel;
}