class Kernel implements Kernel (View source)

Traits

Properties

protected Application $app

The application implementation.

protected Dispatcher $events

The event dispatcher implementation.

protected EventDispatcherInterface|null $symfonyDispatcher

The Symfony event dispatcher implementation.

protected Application|null $artisan

The Artisan application instance.

protected array $commands

The Artisan commands provided by the application.

protected array $commandPaths

The paths where Artisan commands should be automatically discovered.

protected array $commandRoutePaths

The paths where Artisan "routes" should be automatically discovered.

protected bool $commandsLoaded

Indicates if the Closure commands have been loaded.

protected array $loadedPaths

The commands paths that have been "loaded".

protected array $commandLifecycleDurationHandlers

All of the registered command duration handlers.

protected Carbon|null $commandStartedAt

When the currently handled command started.

protected string[] $bootstrappers

The bootstrap classes for the application.

Methods

int
secondsUntil(DateTimeInterface|DateInterval|int $delay)

Get the number of seconds until the given DateTime.

int
availableAt(DateTimeInterface|DateInterval|int $delay = 0)

Get the "available at" UNIX timestamp.

parseDateInterval(DateTimeInterface|DateInterval|int $delay)

If the given value is an interval, convert it to a DateTime instance.

int
currentTime()

Get the current system time as a UNIX timestamp.

string
runTimeForHumans(float $startTime, float $endTime = null)

Given a start time, format the total run time for human readability.

void
__construct(Application $app, Dispatcher $events)

Create a new console kernel instance.

$this
rerouteSymfonyCommandEvents()

Re-route the Symfony command events to their Laravel counterparts.

int
handle(InputInterface $input, OutputInterface|null $output = null)

Run the console application.

void
terminate(InputInterface $input, int $status)

Terminate the application.

void
whenCommandLifecycleIsLongerThan(DateTimeInterface|CarbonInterval|float|int $threshold, callable $handler)

Register a callback to be invoked when the command lifecycle duration exceeds a given amount of time.

Carbon|null
commandStartedAt()

When the command being handled started.

void
schedule(Schedule $schedule)

Define the application's command schedule.

resolveConsoleSchedule()

Resolve a console schedule instance.

DateTimeZone|string|null
scheduleTimezone()

Get the timezone that should be used by default for scheduled events.

string|null
scheduleCache()

Get the name of the cache store that should manage scheduling mutexes.

void
commands()

Register the commands for the application.

command(string $signature, Closure $callback)

Register a Closure based command with the application.

void
load(array|string $paths)

Register all of the commands in the given directory.

string
commandClassFromFile(SplFileInfo $file, string $namespace)

Extract the command class name from the given file path.

void
registerCommand(Command $command)

Register the given command with the console application.

int
call(string $command, array $parameters = [], OutputInterface|null $outputBuffer = null)

Run an Artisan console command by name.

queue(string $command, array $parameters = [])

Queue the given console command.

array
all()

Get all of the commands registered with the console.

string
output()

Get the output for the last run command.

void
bootstrap()

Bootstrap the application for artisan commands.

void
discoverCommands()

Discover the commands that should be automatically loaded.

void
bootstrapWithoutBootingProviders()

Bootstrap the application without booting service providers.

bool
shouldDiscoverCommands()

Determine if the kernel should discover commands.

getArtisan()

Get the Artisan application instance.

void
setArtisan(Application|null $artisan)

Set the Artisan application instance.

$this
addCommands(array $commands)

Set the Artisan commands provided by the application.

$this
addCommandPaths(array $paths)

Set the paths that should have their Artisan commands automatically discovered.

$this
addCommandRoutePaths(array $paths)

Set the paths that should have their Artisan "routes" automatically discovered.

array
bootstrappers()

Get the bootstrap classes for the application.

void
reportException(Throwable $e)

Report the exception to the exception handler.

void
renderException(OutputInterface $output, Throwable $e)

Render the given exception.

Details

protected int secondsUntil(DateTimeInterface|DateInterval|int $delay)

Get the number of seconds until the given DateTime.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

int

protected int availableAt(DateTimeInterface|DateInterval|int $delay = 0)

Get the "available at" UNIX timestamp.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

int

protected DateTimeInterface|int parseDateInterval(DateTimeInterface|DateInterval|int $delay)

If the given value is an interval, convert it to a DateTime instance.

Parameters

DateTimeInterface|DateInterval|int $delay

Return Value

DateTimeInterface|int

protected int currentTime()

Get the current system time as a UNIX timestamp.

Return Value

int

protected string runTimeForHumans(float $startTime, float $endTime = null)

Given a start time, format the total run time for human readability.

Parameters

float $startTime
float $endTime

Return Value

string

void __construct(Application $app, Dispatcher $events)

Create a new console kernel instance.

Parameters

Application $app
Dispatcher $events

Return Value

void

$this rerouteSymfonyCommandEvents()

internal  
 

Re-route the Symfony command events to their Laravel counterparts.

Return Value

$this

int handle(InputInterface $input, OutputInterface|null $output = null)

Run the console application.

Parameters

InputInterface $input
OutputInterface|null $output

Return Value

int

void terminate(InputInterface $input, int $status)

Terminate the application.

Parameters

InputInterface $input
int $status

Return Value

void

void whenCommandLifecycleIsLongerThan(DateTimeInterface|CarbonInterval|float|int $threshold, callable $handler)

Register a callback to be invoked when the command lifecycle duration exceeds a given amount of time.

Parameters

DateTimeInterface|CarbonInterval|float|int $threshold
callable $handler

Return Value

void

Carbon|null commandStartedAt()

When the command being handled started.

Return Value

Carbon|null

protected void schedule(Schedule $schedule)

Define the application's command schedule.

Parameters

Schedule $schedule

Return Value

void

Schedule resolveConsoleSchedule()

Resolve a console schedule instance.

Return Value

Schedule

protected DateTimeZone|string|null scheduleTimezone()

Get the timezone that should be used by default for scheduled events.

Return Value

DateTimeZone|string|null

protected string|null scheduleCache()

Get the name of the cache store that should manage scheduling mutexes.

Return Value

string|null

protected void commands()

Register the commands for the application.

Return Value

void

ClosureCommand command(string $signature, Closure $callback)

Register a Closure based command with the application.

Parameters

string $signature
Closure $callback

Return Value

ClosureCommand

protected void load(array|string $paths)

Register all of the commands in the given directory.

Parameters

array|string $paths

Return Value

void

protected string commandClassFromFile(SplFileInfo $file, string $namespace)

Extract the command class name from the given file path.

Parameters

SplFileInfo $file
string $namespace

Return Value

string

void registerCommand(Command $command)

Register the given command with the console application.

Parameters

Command $command

Return Value

void

int call(string $command, array $parameters = [], OutputInterface|null $outputBuffer = null)

Run an Artisan console command by name.

Parameters

string $command
array $parameters
OutputInterface|null $outputBuffer

Return Value

int

Exceptions

CommandNotFoundException

PendingDispatch queue(string $command, array $parameters = [])

Queue the given console command.

Parameters

string $command
array $parameters

Return Value

PendingDispatch

array all()

Get all of the commands registered with the console.

Return Value

array

string output()

Get the output for the last run command.

Return Value

string

void bootstrap()

Bootstrap the application for artisan commands.

Return Value

void

protected void discoverCommands()

Discover the commands that should be automatically loaded.

Return Value

void

void bootstrapWithoutBootingProviders()

Bootstrap the application without booting service providers.

Return Value

void

protected bool shouldDiscoverCommands()

Determine if the kernel should discover commands.

Return Value

bool

protected Application getArtisan()

Get the Artisan application instance.

Return Value

Application

void setArtisan(Application|null $artisan)

Set the Artisan application instance.

Parameters

Application|null $artisan

Return Value

void

$this addCommands(array $commands)

Set the Artisan commands provided by the application.

Parameters

array $commands

Return Value

$this

$this addCommandPaths(array $paths)

Set the paths that should have their Artisan commands automatically discovered.

Parameters

array $paths

Return Value

$this

$this addCommandRoutePaths(array $paths)

Set the paths that should have their Artisan "routes" automatically discovered.

Parameters

array $paths

Return Value

$this

protected array bootstrappers()

Get the bootstrap classes for the application.

Return Value

array

protected void reportException(Throwable $e)

Report the exception to the exception handler.

Parameters

Throwable $e

Return Value

void

protected void renderException(OutputInterface $output, Throwable $e)

Render the given exception.

Parameters

OutputInterface $output
Throwable $e

Return Value

void