Documentation

KernelInterface extends HttpKernelInterface

The Kernel is the heart of the Symfony system.

It manages an environment made of application kernel and bundles.

Tags
author

Fabien Potencier fabien@symfony.com

Table of Contents

MAIN_REQUEST  = 1
MASTER_REQUEST  = self::MAIN_REQUEST
SUB_REQUEST  = 2
boot()  : mixed
Boots the current kernel.
getBundle()  : BundleInterface
Returns a bundle.
getBundles()  : array<string, BundleInterface>
Gets the registered bundle instances.
getCacheDir()  : string
Gets the cache directory.
getCharset()  : string
Gets the charset of the application.
getContainer()  : ContainerInterface
Gets the current container.
getEnvironment()  : string
Gets the environment.
getLogDir()  : string
Gets the log directory.
getProjectDir()  : string
Gets the project dir (path of the project's composer file).
getStartTime()  : float
Gets the request start time (not available if debug is disabled).
handle()  : Response
Handles a Request to convert it to a Response.
isDebug()  : bool
Checks if debug mode is enabled.
locateResource()  : string
Returns the file path for a given bundle resource.
registerBundles()  : iteratable<mixed, BundleInterface>
Returns an array of bundles to register.
registerContainerConfiguration()  : mixed
Loads the container configuration.
shutdown()  : mixed
Shutdowns the kernel.

Constants

MASTER_REQUEST

public mixed MASTER_REQUEST = self::MAIN_REQUEST
Tags
deprecated

since symfony/http-kernel 5.3, use MAIN_REQUEST instead. To ease the migration, this constant won't be removed until Symfony 7.0.

Methods

boot()

Boots the current kernel.

public boot() : mixed
Return values
mixed

getCacheDir()

Gets the cache directory.

public getCacheDir() : string

Since Symfony 5.2, the cache directory should be used for caches that are written at runtime. For caches and artifacts that can be warmed at compile-time and deployed as read-only, use the new "build directory" returned by the getBuildDir() method.

Return values
string

getCharset()

Gets the charset of the application.

public getCharset() : string
Return values
string

getEnvironment()

Gets the environment.

public getEnvironment() : string
Return values
string

getLogDir()

Gets the log directory.

public getLogDir() : string
Return values
string

getProjectDir()

Gets the project dir (path of the project's composer file).

public getProjectDir() : string
Return values
string

getStartTime()

Gets the request start time (not available if debug is disabled).

public getStartTime() : float
Return values
float

handle()

Handles a Request to convert it to a Response.

public handle(Request $request[, int $type = self::MAIN_REQUEST ][, bool $catch = true ]) : Response

When $catch is true, the implementation must catch all exceptions and do its best to convert them to a Response instance.

Parameters
$request : Request
$type : int = self::MAIN_REQUEST

The type of the request (one of HttpKernelInterface::MAIN_REQUEST or HttpKernelInterface::SUB_REQUEST)

$catch : bool = true

Whether to catch exceptions or not

Tags
throws
Exception

When an Exception occurs during processing

Return values
Response

isDebug()

Checks if debug mode is enabled.

public isDebug() : bool
Return values
bool

locateResource()

Returns the file path for a given bundle resource.

public locateResource(string $name) : string

A Resource can be a file or a directory.

The resource name must follow the following pattern:

"@BundleName/path/to/a/file.something"

where BundleName is the name of the bundle and the remaining part is the relative path in the bundle.

Parameters
$name : string
Tags
throws
InvalidArgumentException

if the file cannot be found or the name is not valid

throws
RuntimeException

if the name contains invalid/unsafe characters

Return values
string

shutdown()

Shutdowns the kernel.

public shutdown() : mixed

This method is mainly useful when doing functional testing.

Return values
mixed

Search results