CodeIgniter v4.5 API

Serve extends BaseCommand
in package

Launch the PHP development server

Not testable, as it throws phpunit for a loop :-/

Tags
codeCoverageIgnore

Table of Contents

Properties

$arguments  : array<string, string>
$commands  : Commands
$description  : string
$group  : string
$logger  : LoggerInterface
$name  : string
$options  : array<string, string>
$usage  : string
$arguments  : array<string, string>
Arguments
$commands  : Commands
Instance of Commands so commands can call other commands.
$description  : string
Description
$group  : string
Group
$logger  : LoggerInterface
The Logger to use for a command
$name  : string
Name
$options  : array<string, string>
Options
$portOffset  : int
The current port offset.
$tries  : int
The max number of ports to attempt to serve from
$usage  : string
Usage

Methods

__construct()  : mixed
__get()  : array<string, string>|Commands|LoggerInterface|string|null
Makes it simple to access our protected properties.
__isset()  : bool
Makes it simple to check our protected properties.
getPad()  : int
Get pad for $key => $value array output
run()  : int|void
Run the server
setPad()  : string
Pads our string out so that all titles are the same length to nicely line up descriptions.
showHelp()  : void
Show Help includes (Usage, Arguments, Description, Options).
call()  : int|void
Can be used by a command to run other commands.
showError()  : void
A simple method to display an error with line/file, in child commands.

Properties

$arguments

Arguments

protected array<string, string> $arguments = []

$commands

Instance of Commands so commands can call other commands.

protected Commands $commands

$description

Description

protected string $description = 'Launches the CodeIgniter PHP-Development Server.'

$group

Group

protected string $group = 'CodeIgniter'

$logger

The Logger to use for a command

protected LoggerInterface $logger

$name

Name

protected string $name = 'serve'

$options

Options

protected array<string, string> $options = ['--php' => 'The PHP Binary [default: "PHP_BINARY"]', '--host' => 'The HTTP Host [default: "localhost"]', '--port' => 'The HTTP Host Port [default: "8080"]']

$portOffset

The current port offset.

protected int $portOffset = 0

$tries

The max number of ports to attempt to serve from

protected int $tries = 10

$usage

Usage

protected string $usage = 'serve'

Methods

__construct()

public __construct(LoggerInterface $logger, Commands $commands) : mixed
Parameters
$logger : LoggerInterface
$commands : Commands

__get()

Makes it simple to access our protected properties.

public __get(string $key) : array<string, string>|Commands|LoggerInterface|string|null
Parameters
$key : string
Return values
array<string, string>|Commands|LoggerInterface|string|null

__isset()

Makes it simple to check our protected properties.

public __isset(string $key) : bool
Parameters
$key : string
Return values
bool

getPad()

Get pad for $key => $value array output

public getPad(array<string, string> $array, int $pad) : int

Use setPad() instead.

Parameters
$array : array<string, string>
$pad : int
Tags
codeCoverageIgnore
Return values
int

run()

Run the server

public run(array<string|int, mixed> $params) : int|void
Parameters
$params : array<string|int, mixed>
Return values
int|void

setPad()

Pads our string out so that all titles are the same length to nicely line up descriptions.

public setPad(string $item, int $max[, int $extra = 2 ][, int $indent = 0 ]) : string
Parameters
$item : string
$max : int
$extra : int = 2

How many extra spaces to add at the end

$indent : int = 0
Return values
string

showHelp()

Show Help includes (Usage, Arguments, Description, Options).

public showHelp() : void

call()

Can be used by a command to run other commands.

protected call(string $command[, array<int|string, string|null> $params = [] ]) : int|void
Parameters
$command : string
$params : array<int|string, string|null> = []
Tags
throws
ReflectionException
Return values
int|void

showError()

A simple method to display an error with line/file, in child commands.

protected showError(Throwable $e) : void
Parameters
$e : Throwable

        
On this page

Search results