class ServerCommand extends Command (View source)

internal  This command makes no guarantee of an API for Drupal extensions.
 

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

Properties

protected object $classLoader

The class loader.

Methods

__construct(object $class_loader)

Constructs a new ServerCommand command.

configure()

{@inheritdoc}

execute(InputInterface $input, OutputInterface $output)

{@inheritdoc}

boot()

Boots up a Drupal environment.

int|false
findAvailablePort(string $host)

Finds an available port.

openBrowser(string $url, SymfonyStyle $io)

Opens a URL in your system default browser.

string
getOneTimeLoginUrl()

Gets a one time login URL for user 1.

int
start(string $host, int $port, DrupalKernelInterface $kernel, InputInterface $input, SymfonyStyle $io)

Starts up a webserver with a running Drupal.

string
getSitePath()

Gets the site path.

Details

__construct(object $class_loader)

Constructs a new ServerCommand command.

Parameters

object $class_loader

The class loader.

protected configure()

{@inheritdoc}

protected execute(InputInterface $input, OutputInterface $output)

{@inheritdoc}

Parameters

InputInterface $input
OutputInterface $output

protected DrupalKernelInterface boot()

Boots up a Drupal environment.

Return Value

DrupalKernelInterface

The Drupal kernel.

Exceptions

Exception

protected int|false findAvailablePort(string $host)

Finds an available port.

Parameters

string $host

The host to find a port on.

Return Value

int|false

The available port or FALSE, if no available port found,

protected openBrowser(string $url, SymfonyStyle $io)

Opens a URL in your system default browser.

Parameters

string $url

The URL to browser to.

SymfonyStyle $io

The IO.

protected string getOneTimeLoginUrl()

Gets a one time login URL for user 1.

Return Value

string

The one time login URL for user 1.

protected int start(string $host, int $port, DrupalKernelInterface $kernel, InputInterface $input, SymfonyStyle $io)

Starts up a webserver with a running Drupal.

Parameters

string $host

The hostname of the webserver.

int $port

The port to start the webserver on.

DrupalKernelInterface $kernel

The Drupal kernel.

InputInterface $input

The input.

SymfonyStyle $io

The IO.

Return Value

int

The exit status of the PHP in-built webserver command.

protected string getSitePath()

Gets the site path.

Defaults to 'sites/default'. For testing purposes this can be overridden using the DRUPAL_DEV_SITE_PATH environment variable.

Return Value

string

The site path to use.