function ServerCommand::boot

Same name in other branches
  1. 8.9.x 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()
  3. 11.x 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

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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.