Class

Symfony\Component\HttpKernel\Kernel

abstract class Kernel implements KernelInterface

The Kernel is the heart of the Symfony system.

It manages an environment made of bundles.

Constants

VERSION

VERSION_ID

MAJOR_VERSION

MINOR_VERSION

RELEASE_VERSION

EXTRA_VERSION

Methods

__construct(string $environment, Boolean $debug)

Constructor.

init()

__clone()

boot()

Boots the current kernel.

shutdown()

Shutdowns the kernel.

Response handle(Request $request, integer $type = HttpKernelInterface::MASTER_REQUEST, Boolean $catch = true)

Handles a Request to convert it to a Response.

array getBundles()

Gets the registered bundle instances.

Boolean isClassInActiveBundle(string $class)

Checks if a given class name belongs to an active bundle.

BundleInterface|Array getBundle(string $name, Boolean $first = true)

Returns a bundle and optionally its descendants by its name.

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

Returns the file path for a given resource.

string getName()

Gets the name of the kernel

string getEnvironment()

Gets the environment.

Boolean isDebug()

Checks if debug mode is enabled.

string getRootDir()

Gets the application root dir.

ContainerInterface getContainer()

Gets the current container.

loadClassCache(string $name = 'classes', string $extension = '.php')

Loads the PHP class cache.

setClassCache(array $classes)

Used internally.

integer getStartTime()

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

string getCacheDir()

Gets the cache directory.

string getLogDir()

Gets the log directory.

static string stripComments(string $source)

Removes comments from a PHP source string.

serialize()

unserialize($data)

Details

at line 74
public __construct(string $environment, Boolean $debug)

Constructor.

Parameters

string $environment The environment
Boolean $debug Whether to enable debugging or not

at line 90
public init()

at line 106
public __clone()

at line 121
public boot()

Boots the current kernel.

at line 148
public shutdown()

Shutdowns the kernel.

This method is mainly useful when doing functional testing.

at line 169
public Response handle(Request $request, integer $type = HttpKernelInterface::MASTER_REQUEST, Boolean $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
integer $type The type of the request (one of HttpKernelInterface::MASTERREQUEST or HttpKernelInterface::SUBREQUEST)
Boolean $catch Whether to catch exceptions or not

Return Value

Response A Response instance

Exceptions

Exception When an Exception occurs during processing

at line 195
public array getBundles()

Gets the registered bundle instances.

Return Value

array An array of registered bundle instances

at line 209
public Boolean isClassInActiveBundle(string $class)

Checks if a given class name belongs to an active bundle.

Parameters

string $class A class name

Return Value

Boolean true if the class belongs to an active bundle, false otherwise

at line 232
public BundleInterface|Array getBundle(string $name, Boolean $first = true)

Returns a bundle and optionally its descendants by its name.

Parameters

string $name Bundle name
Boolean $first Whether to return the first bundle only or together with its descendants

Return Value

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

Exceptions

InvalidArgumentException when the bundle is not enabled

at line 276
public string|array locateResource(string $name, string $dir = null, Boolean $first = true)

Returns the file path for a given resource.

A Resource can be a file or a directory.

The resource name must follow the following pattern:

Parameters

string $name A resource name to locate
string $dir A directory where to look for the resource first
Boolean $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
RuntimeException if a custom resource is hidden by a resource in a derived bundle

at line 337
public string getName()

Gets the name of the kernel

Return Value

string The kernel name

at line 349
public string getEnvironment()

Gets the environment.

Return Value

string The current environment

at line 361
public Boolean isDebug()

Checks if debug mode is enabled.

Return Value

Boolean true if debug mode is enabled, false otherwise

at line 373
public string getRootDir()

Gets the application root dir.

Return Value

string The application root dir

at line 390
public ContainerInterface getContainer()

Gets the current container.

Return Value

ContainerInterface A ContainerInterface instance

at line 401
public loadClassCache(string $name = 'classes', string $extension = '.php')

Loads the PHP class cache.

Parameters

string $name The cache name prefix
string $extension File extension of the resulting file

at line 411
public setClassCache(array $classes)

Used internally.

Parameters

array $classes

at line 423
public integer getStartTime()

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

Return Value

integer The request start timestamp

at line 435
public string getCacheDir()

Gets the cache directory.

Return Value

string The cache directory

at line 447
public string getLogDir()

Gets the log directory.

Return Value

string The log directory

at line 709
static public string stripComments(string $source)

Removes comments from a PHP source string.

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

Parameters

string $source A PHP string

Return Value

string The PHP string with the comments removed

at line 730
public serialize()

at line 735
public unserialize($data)

Parameters

$data