interface KernelInterface implementsHttpKernelInterface

The Kernel is the heart of the Symfony system.

It manages an environment made of application kernel and bundles.

Methods

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

Handles a Request to convert it to a Response.

iterable
registerBundles()

Returns an array of bundles to register.

void
registerContainerConfiguration(LoaderInterface$loader)

Loads the container configuration.

void
boot()

Boots the current kernel.

void
shutdown()

Shutdowns the kernel.

array
getBundles()

Gets the registered bundle instances.

getBundle(string$name)

Returns a bundle.

string
locateResource(string$name)

Returns the file path for a given bundle resource.

string
getEnvironment()

Gets the environment.

bool
isDebug()

Checks if debug mode is enabled.

string
getProjectDir()

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

ContainerInterface
getContainer()

Gets the current container.

float
getStartTime()

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

string
getCacheDir()

Gets the cache directory.

string
getBuildDir()

Returns the build directory.

string
getLogDir()

Gets the log directory.

string
getCharset()

Gets the charset of the application.

Details

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

Handles a Request to convert it to a 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
int $type
bool $catch

Return Value

Response

Exceptions

Exception When an Exception occurs during processing

iterable registerBundles()

Returns an array of bundles to register.

Return Value

iterable BundleInterface>

void registerContainerConfiguration(LoaderInterface$loader)

Loads the container configuration.

Parameters

LoaderInterface $loader

Return Value

void

void boot()

Boots the current kernel.

Return Value

void

void shutdown()

Shutdowns the kernel.

This method is mainly useful when doing functional testing.

Return Value

void

array getBundles()

Gets the registered bundle instances.

Return Value

array BundleInterface>

BundleInterface getBundle(string$name)

Returns a bundle.

Parameters

string $name

Return Value

BundleInterface

Exceptions

InvalidArgumentException when the bundle is not enabled

string locateResource(string$name)

Returns the file path for a given bundle resource.

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

string $name

Return Value

string

Exceptions

InvalidArgumentException if the file cannot be found or the name is not valid
RuntimeException if the name contains invalid/unsafe characters

string getEnvironment()

Gets the environment.

Return Value

string

bool isDebug()

Checks if debug mode is enabled.

Return Value

bool

string getProjectDir()

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

Return Value

string

ContainerInterface getContainer()

Gets the current container.

Return Value

ContainerInterface

float getStartTime()

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

Return Value

float

string getCacheDir()

Gets the cache directory.

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 {see getBuildDir()} method.

Return Value

string

string getBuildDir()

Returns the build directory.

This directory should be used to store build artifacts, and can be read-only at runtime. Caches written at runtime should be stored in the "cache directory" ({see KernelInterface::getCacheDir()}).

Return Value

string

string getLogDir()

Gets the log directory.

Return Value

string

string getCharset()

Gets the charset of the application.

Return Value

string