Documentation

Kernel
in package
implements KernelInterface, RebootableInterface, TerminableInterface

The Kernel is the heart of the Symfony system.

It manages an environment made of bundles.

Tags
author

Fabien Potencier fabien@symfony.com

Interfaces, Classes and Traits

KernelInterface
The Kernel is the heart of the Symfony system.
RebootableInterface
Allows the Kernel to be rebooted using a temporary cache directory.
TerminableInterface
Terminable extends the Kernel request/response cycle with dispatching a post response event after sending the response and before shutting down the kernel.

Table of Contents

END_OF_LIFE  = '11/2021'
END_OF_MAINTENANCE  = '11/2020'
EXTRA_VERSION  = ''
MAJOR_VERSION  = 3
MINOR_VERSION  = 4
RELEASE_VERSION  = 46
VERSION  = '3.4.46'
VERSION_ID  = 30446
$booted  : mixed
$bundleMap  : mixed
$bundles  : array<string|int, BundleInterface>
$container  : mixed
$debug  : mixed
$environment  : mixed
$loadClassCache  : mixed
$name  : mixed
$rootDir  : mixed
$startTime  : mixed
$projectDir  : mixed
$requestStackSize  : mixed
$resetServices  : mixed
$warmupDir  : mixed
__clone()  : mixed
__construct()  : mixed
boot()  : mixed
Boots the current kernel.
getBundle()  : BundleInterface|array<string|int, BundleInterface>
Returns a bundle and optionally its descendants by its name.
getBundles()  : array<string|int, BundleInterface>
Gets the registered bundle instances.
getCacheDir()  : string
Gets the cache directory.
getCharset()  : string
Gets the charset of the application.
getContainer()  : ContainerInterface|null
Gets the current container.
getEnvironment()  : string
Gets the environment.
getLogDir()  : string
Gets the log directory.
getName()  : string
Gets the name of the kernel.
getProjectDir()  : string
Gets the application root dir (path of the project's composer file).
getRootDir()  : string
Gets the application root dir (path of the project's Kernel class).
getStartTime()  : float
Gets the request start time (not available if debug is disabled).
handle()  : mixed
{@inheritdoc}
isDebug()  : bool
Checks if debug mode is enabled.
loadClassCache()  : mixed
Loads the PHP class cache.
locateResource()  : string|array<string|int, mixed>
Returns the file path for a given resource.
reboot()  : mixed
Reboots a kernel.
serialize()  : mixed
shutdown()  : mixed
Shutdowns the kernel.
stripComments()  : string
Removes comments from a PHP source string.
terminate()  : mixed
Terminates a request/response cycle.
unserialize()  : mixed
build()  : mixed
The extension point similar to the Bundle::build() method.
buildContainer()  : ContainerBuilder
Builds the service container.
doLoadClassCache()  : mixed
dumpContainer()  : mixed
Dumps the service container to PHP code in the cache.
getContainerBaseClass()  : string
Gets the container's base class.
getContainerBuilder()  : ContainerBuilder
Gets a new ContainerBuilder instance used to build the service container.
getContainerClass()  : string
Gets the container class.
getContainerLoader()  : DelegatingLoader
Returns a loader for the container.
getEnvParameters()  : array<string|int, mixed>
Gets the environment parameters.
getHttpKernel()  : HttpKernelInterface
Gets a HTTP kernel from the container.
getKernelParameters()  : array<string|int, mixed>
Returns the kernel parameters.
initializeBundles()  : mixed
Initializes the data structures related to the bundle management.
initializeContainer()  : mixed
Initializes the service container.
prepareContainer()  : mixed
Prepares the ContainerBuilder before it is compiled.

Constants

END_OF_LIFE

public mixed END_OF_LIFE = '11/2021'

END_OF_MAINTENANCE

public mixed END_OF_MAINTENANCE = '11/2020'

EXTRA_VERSION

public mixed EXTRA_VERSION = ''

MAJOR_VERSION

public mixed MAJOR_VERSION = 3

MINOR_VERSION

public mixed MINOR_VERSION = 4

RELEASE_VERSION

public mixed RELEASE_VERSION = 46

VERSION

public mixed VERSION = '3.4.46'

VERSION_ID

public mixed VERSION_ID = 30446

Properties

$booted

protected mixed $booted = false

$bundleMap

protected mixed $bundleMap

$container

protected mixed $container

$environment

protected mixed $environment

$loadClassCache

protected mixed $loadClassCache

$rootDir

protected mixed $rootDir

$startTime

protected mixed $startTime

$projectDir

private mixed $projectDir

$requestStackSize

private mixed $requestStackSize = 0

$resetServices

private mixed $resetServices = false

$warmupDir

private mixed $warmupDir

Methods

__clone()

public __clone() : mixed
Return values
mixed

__construct()

public __construct(string $environment, bool $debug) : mixed
Parameters
$environment : string

The environment

$debug : bool

Whether to enable debugging or not

Return values
mixed

boot()

Boots the current kernel.

public boot() : mixed
Return values
mixed

getBundle()

Returns a bundle and optionally its descendants by its name.

public getBundle(mixed $name[, mixed $first = true ]) : BundleInterface|array<string|int, BundleInterface>
Parameters
$name : mixed

Bundle name

$first : mixed = true

Whether to return the first bundle only or together with its descendants

Return values
BundleInterface|array<string|int, BundleInterface>

A BundleInterface instance or an array of BundleInterface instances if $first is false

getBundles()

Gets the registered bundle instances.

public getBundles() : array<string|int, BundleInterface>
Return values
array<string|int, BundleInterface>

An array of registered bundle instances

getCacheDir()

Gets the cache directory.

public getCacheDir() : string
Return values
string

The cache directory

getCharset()

Gets the charset of the application.

public getCharset() : string
Return values
string

The charset

getContainer()

Gets the current container.

public getContainer() : ContainerInterface|null
Return values
ContainerInterface|null

A ContainerInterface instance or null when the Kernel is shutdown

getEnvironment()

Gets the environment.

public getEnvironment() : string
Return values
string

The current environment

getLogDir()

Gets the log directory.

public getLogDir() : string
Return values
string

The log directory

getName()

Gets the name of the kernel.

public getName() : string
Return values
string

The kernel name

getProjectDir()

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

public getProjectDir() : string
Return values
string

The project root dir

getRootDir()

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

public getRootDir() : string
Return values
string

The Kernel root dir

getStartTime()

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

public getStartTime() : float
Return values
float

The request start timestamp

handle()

{@inheritdoc}

public handle(Request $request[, mixed $type = HttpKernelInterface::MASTER_REQUEST ][, mixed $catch = true ]) : mixed
Parameters
$request : Request
$type : mixed = HttpKernelInterface::MASTER_REQUEST
$catch : mixed = true
Return values
mixed

isDebug()

Checks if debug mode is enabled.

public isDebug() : bool
Return values
bool

true if debug mode is enabled, false otherwise

loadClassCache()

Loads the PHP class cache.

public loadClassCache([string $name = 'classes' ][, string $extension = '.php' ]) : mixed

This methods only registers the fact that you want to load the cache classes. The cache will actually only be loaded when the Kernel is booted.

That optimization is mainly useful when using the HttpCache class in which case the class cache is not loaded if the Response is in the cache.

Parameters
$name : string = 'classes'

The cache name prefix

$extension : string = '.php'

File extension of the resulting file

Tags
deprecated

since version 3.3, to be removed in 4.0. The class cache is not needed anymore when using PHP 7.0.

Return values
mixed

locateResource()

Returns the file path for a given resource.

public locateResource(mixed $name[, mixed $dir = null ][, mixed $first = true ]) : string|array<string|int, mixed>
Parameters
$name : mixed

A resource name to locate

$dir : mixed = null

A directory where to look for the resource first

$first : mixed = true

Whether to return the first path or paths for all matching bundles

Tags
throws
RuntimeException

if a custom resource is hidden by a resource in a derived bundle

Return values
string|array<string|int, mixed>

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

reboot()

Reboots a kernel.

public reboot(mixed $warmupDir) : mixed
Parameters
$warmupDir : mixed

pass null to reboot in the regular cache directory

Return values
mixed

serialize()

public serialize() : mixed
Return values
mixed

shutdown()

Shutdowns the kernel.

public shutdown() : mixed
Return values
mixed

stripComments()

Removes comments from a PHP source string.

public static stripComments(string $source) : string

We don't use the PHP php_strip_whitespace() function as we want the content to be readable and well-formatted.

Parameters
$source : string

A PHP string

Return values
string

The PHP string with the comments removed

terminate()

Terminates a request/response cycle.

public terminate(Request $request, Response $response) : mixed
Parameters
$request : Request
$response : Response
Return values
mixed

unserialize()

public unserialize(mixed $data) : mixed
Parameters
$data : mixed
Return values
mixed

build()

The extension point similar to the Bundle::build() method.

protected build(ContainerBuilder $container) : mixed

Use this method to register compiler passes and manipulate the container during the building process.

Parameters
$container : ContainerBuilder
Return values
mixed

buildContainer()

Builds the service container.

protected buildContainer() : ContainerBuilder
Tags
throws
RuntimeException
Return values
ContainerBuilder

The compiled service container

doLoadClassCache()

protected doLoadClassCache(mixed $name, mixed $extension) : mixed
Parameters
$name : mixed
$extension : mixed
Tags
deprecated

since version 3.3, to be removed in 4.0.

Return values
mixed

dumpContainer()

Dumps the service container to PHP code in the cache.

protected dumpContainer(ConfigCache $cache, ContainerBuilder $container, string $class, string $baseClass) : mixed
Parameters
$cache : ConfigCache

The config cache

$container : ContainerBuilder

The service container

$class : string

The name of the class to generate

$baseClass : string

The name of the container's base class

Return values
mixed

getContainerBaseClass()

Gets the container's base class.

protected getContainerBaseClass() : string

All names except Container must be fully qualified.

Return values
string

getContainerBuilder()

Gets a new ContainerBuilder instance used to build the service container.

protected getContainerBuilder() : ContainerBuilder
Return values
ContainerBuilder

getContainerClass()

Gets the container class.

protected getContainerClass() : string
Return values
string

The container class

getContainerLoader()

Returns a loader for the container.

protected getContainerLoader(ContainerInterface $container) : DelegatingLoader
Parameters
$container : ContainerInterface
Return values
DelegatingLoader

The loader

getEnvParameters()

Gets the environment parameters.

protected getEnvParameters() : array<string|int, mixed>

Only the parameters starting with "SYMFONY__" are considered.

Tags
deprecated

since version 3.3, to be removed in 4.0

Return values
array<string|int, mixed>

An array of parameters

getKernelParameters()

Returns the kernel parameters.

protected getKernelParameters() : array<string|int, mixed>
Return values
array<string|int, mixed>

An array of kernel parameters

initializeBundles()

Initializes the data structures related to the bundle management.

protected initializeBundles() : mixed
  • the bundles property maps a bundle name to the bundle instance,
  • the bundleMap property maps a bundle name to the bundle inheritance hierarchy (most derived bundle first).
Tags
throws
LogicException

if two bundles share a common name

throws
LogicException

if a bundle tries to extend a non-registered bundle

throws
LogicException

if a bundle tries to extend itself

throws
LogicException

if two bundles extend the same ancestor

Return values
mixed

initializeContainer()

Initializes the service container.

protected initializeContainer() : mixed

The cached version of the service container is used when fresh, otherwise the container is built.

Return values
mixed

prepareContainer()

Prepares the ContainerBuilder before it is compiled.

protected prepareContainer(ContainerBuilder $container) : mixed
Parameters
$container : ContainerBuilder
Return values
mixed

Search results