interface KernelInterface implements HttpKernelInterface, Serializable

The Kernel is the heart of the Symfony system.

It manages an environment made of application kernel and bundles.

Methods

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

Handles a Request to convert it to a Response.

iterable|BundleInterface[]
registerBundles()

Returns an array of bundles to register.

registerContainerConfiguration(LoaderInterface $loader)

Loads the container configuration.

boot()

Boots the current kernel.

shutdown()

Shutdowns the kernel.

getBundles()

Gets the registered bundle instances.

getBundle(string $name)

Returns a bundle.

string|array
locateResource(string $name, string $dir = null, bool $first = true)

Returns the file path for a given bundle resource.

string
getName() deprecated

Gets the name of the kernel.

string
getEnvironment()

Gets the environment.

bool
isDebug()

Checks if debug mode is enabled.

string
getRootDir() deprecated

Gets the application root dir (path of the project's Kernel class).

getContainer()

Gets the current container.

int
getStartTime()

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

string
getCacheDir()

Gets the cache directory.

string
getLogDir()

Gets the log directory.

string
getCharset()

Gets the charset of the application.

string
getProjectDir()

Gets the project dir (path of the project's composer file) - not defining it is deprecated since Symfony 4.2

Details

in HttpKernelInterface at line 42
Response handle(Request $request, int $type = self::MASTER_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 A Request instance
int $type The type of the request (one of HttpKernelInterface::MASTER_REQUEST or HttpKernelInterface::SUB_REQUEST)
bool $catch Whether to catch exceptions or not

Return Value

Response A Response instance

Exceptions

Exception When an Exception occurs during processing

at line 34
iterable|BundleInterface[] registerBundles()

Returns an array of bundles to register.

Return Value

iterable|BundleInterface[] An iterable of bundle instances

at line 39
registerContainerConfiguration(LoaderInterface $loader)

Loads the container configuration.

Parameters

LoaderInterface $loader

at line 44
boot()

Boots the current kernel.

at line 51
shutdown()

Shutdowns the kernel.

This method is mainly useful when doing functional testing.

at line 58
BundleInterface[] getBundles()

Gets the registered bundle instances.

Return Value

BundleInterface[] An array of registered bundle instances

at line 69
BundleInterface getBundle(string $name)

Returns a bundle.

Parameters

string $name Bundle name

Return Value

BundleInterface A BundleInterface instance

Exceptions

InvalidArgumentException when the bundle is not enabled

at line 99
string|array locateResource(string $name, string $dir = null, bool $first = true)

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.

If $dir is passed, and the first segment of the path is "Resources", this method will look for a file named:

$dir/<BundleName>/path/without/Resources

before looking in the bundle resource folder.

Parameters

string $name A resource name to locate
string $dir A directory where to look for the resource first
bool $first Whether to return the first path or paths for all matching bundles

Return Value

string|array The absolute path of the resource or an array if $first is false

Exceptions

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

at line 108
string getName() deprecated

deprecated since Symfony 4.2

Gets the name of the kernel.

Return Value

string The kernel name

at line 115
string getEnvironment()

Gets the environment.

Return Value

string The current environment

at line 122
bool isDebug()

Checks if debug mode is enabled.

Return Value

bool true if debug mode is enabled, false otherwise

at line 131
string getRootDir() deprecated

deprecated since Symfony 4.2

Gets the application root dir (path of the project's Kernel class).

Return Value

string The Kernel root dir

at line 138
ContainerInterface|null getContainer()

Gets the current container.

Return Value

ContainerInterface|null A ContainerInterface instance or null when the Kernel is shutdown

at line 145
int getStartTime()

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

Return Value

int The request start timestamp

at line 152
string getCacheDir()

Gets the cache directory.

Return Value

string The cache directory

at line 159
string getLogDir()

Gets the log directory.

Return Value

string The log directory

at line 166
string getCharset()

Gets the charset of the application.

Return Value

string The charset

at line 27
string getProjectDir()

Gets the project dir (path of the project's composer file) - not defining it is deprecated since Symfony 4.2

Return Value

string