Symfony2 API
Interface

Symfony\Component\HttpKernel\KernelInterface

interface KernelInterface implements HttpKernelInterface, Serializable

The Kernel is the heart of the Symfony system.

It manages an environment made of bundles.

Methods

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

Handles a Request to convert it to a Response.

from HttpKernelInterface
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.

BundleInterface[] getBundles()

Gets the registered bundle instances.

bool isClassInActiveBundle(string $class)

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

BundleInterface|BundleInterface[] getBundle(string $name, bool $first = true)

Returns a bundle and optionally its descendants by its name.

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

Returns the file path for a given resource.

string getName()

Gets the name of the kernel.

string getEnvironment()

Gets the environment.

bool isDebug()

Checks if debug mode is enabled.

string getRootDir()

Gets the application root dir.

ContainerInterface 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.

Details

in HttpKernelInterface at line 46
public 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::MASTERREQUEST or HttpKernelInterface::SUBREQUEST)
bool $catch Whether to catch exceptions or not

Return Value

Response A Response instance

Exceptions

Exception When an Exception occurs during processing

at line 36
public BundleInterface[] registerBundles()

Returns an array of bundles to register.

Return Value

BundleInterface[] An array of bundle instances.

at line 45
public registerContainerConfiguration(LoaderInterface $loader)

Loads the container configuration.

Parameters

LoaderInterface $loader A LoaderInterface instance

at line 52
public boot()

Boots the current kernel.

at line 61
public shutdown()

Shutdowns the kernel.

This method is mainly useful when doing functional testing.

at line 70
public BundleInterface[] getBundles()

Gets the registered bundle instances.

Return Value

BundleInterface[] An array of registered bundle instances

at line 83
public bool isClassInActiveBundle(string $class)

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

Parameters

string $class A class name

Return Value

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

at line 97
public BundleInterface|BundleInterface[] getBundle(string $name, bool $first = true)

Returns a bundle and optionally its descendants by its name.

Parameters

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

Return Value

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

Exceptions

InvalidArgumentException when the bundle is not enabled

at line 127
public string|array locateResource(string $name, string $dir = null, bool $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
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 136
public string getName()

Gets the name of the kernel.

Return Value

string The kernel name

at line 145
public string getEnvironment()

Gets the environment.

Return Value

string The current environment

at line 154
public bool isDebug()

Checks if debug mode is enabled.

Return Value

bool true if debug mode is enabled, false otherwise

at line 163
public string getRootDir()

Gets the application root dir.

Return Value

string The application root dir

at line 172
public ContainerInterface getContainer()

Gets the current container.

Return Value

ContainerInterface A ContainerInterface instance

at line 181
public int getStartTime()

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

Return Value

int The request start timestamp

at line 190
public string getCacheDir()

Gets the cache directory.

Return Value

string The cache directory

at line 199
public string getLogDir()

Gets the log directory.

Return Value

string The log directory

at line 208
public string getCharset()

Gets the charset of the application.

Return Value

string The charset