abstract class Kernel implements KernelInterface, RebootableInterface, TerminableInterface
The Kernel is the heart of the Symfony system.
It manages an environment made of bundles.
VERSION | |
VERSION_ID | |
MAJOR_VERSION | |
MINOR_VERSION | |
RELEASE_VERSION | |
EXTRA_VERSION | |
END_OF_MAINTENANCE | |
END_OF_LIFE |
protected BundleInterface[] | $bundles | ||
protected | $container | ||
protected | $rootDir | ||
protected | $environment | ||
protected | $debug | ||
protected | $booted | ||
protected | $name | ||
protected | $startTime |
__construct(string $environment, bool $debug) | ||
__clone() | ||
boot() Boots the current kernel. | ||
reboot(string|null $warmupDir) Reboots a kernel. | ||
terminate(Request $request, Response $response) Terminates a request/response cycle. | ||
shutdown() Shutdowns the kernel. | ||
Response | handle(Request $request, int $type = HttpKernelInterface::MASTER_REQUEST, bool $catch = true) Handles a Request to convert it to a Response. | |
HttpKernel | getHttpKernel() Gets a HTTP kernel from the container. | |
BundleInterface[] | getBundles() Gets the registered bundle instances. | |
BundleInterface | 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() 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 (path of the project's Kernel class). | |
string | getProjectDir() Gets the application root dir (path of the project's composer file). | |
ContainerInterface|null | getContainer() Gets the current container. | |
setAnnotatedClassCache(array $annotatedClasses) | ||
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. | |
array | getAnnotatedClassesToCompile() Gets the patterns defining the classes to parse and cache for annotations. | |
initializeBundles() Initializes bundles. | ||
build(ContainerBuilder $container) The extension point similar to the Bundle::build() method. | ||
string | getContainerClass() Gets the container class. | |
string | getContainerBaseClass() Gets the container's base class. | |
initializeContainer() Initializes the service container. | ||
array | getKernelParameters() Returns the kernel parameters. | |
ContainerBuilder | buildContainer() Builds the service container. | |
prepareContainer(ContainerBuilder $container) Prepares the ContainerBuilder before it is compiled. | ||
ContainerBuilder | getContainerBuilder() Gets a new ContainerBuilder instance used to build the service container. | |
dumpContainer(ConfigCache $cache, ContainerBuilder $container, string $class, string $baseClass) Dumps the service container to PHP code in the cache. | ||
DelegatingLoader | getContainerLoader(ContainerInterface $container) Returns a loader for the container. | |
static string | stripComments(string $source) Removes comments from a PHP source string. | |
serialize() | ||
unserialize($data) |
string | $environment | |
bool | $debug |
Boots the current kernel.
Reboots a kernel.
The getCacheDir() method of a rebootable kernel should not be called while building the container. Use the %kernel.cache_dir% parameter instead.
string|null | $warmupDir | pass null to reboot in the regular cache directory |
Terminates a request/response cycle.
Should be called after sending the response and before shutting down the kernel.
Request | $request | |
Response | $response |
Shutdowns the kernel.
This method is mainly useful when doing functional testing.
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.
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 |
Response | A Response instance |
Exception | When an Exception occurs during processing |
Gets a HTTP kernel from the container.
HttpKernel |
Gets the registered bundle instances.
BundleInterface[] | An array of registered bundle instances |
Returns a bundle.
string | $name | Bundle name |
BundleInterface | A BundleInterface instance |
InvalidArgumentException | when the bundle is not enabled |
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.
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 |
string|array | The absolute path of the resource or an array if $first is false |
InvalidArgumentException | if the file cannot be found or the name is not valid |
RuntimeException | if the name contains invalid/unsafe characters |
Gets the name of the kernel.
string | The kernel name |
Gets the environment.
string | The current environment |
Checks if debug mode is enabled.
bool | true if debug mode is enabled, false otherwise |
Gets the application root dir (path of the project's Kernel class).
string | The Kernel root dir |
Gets the application root dir (path of the project's composer file).
string | The project root dir |
Gets the current container.
ContainerInterface|null | A ContainerInterface instance or null when the Kernel is shutdown |
array | $annotatedClasses |
Gets the request start time (not available if debug is disabled).
int | The request start timestamp |
Gets the cache directory.
string | The cache directory |
Gets the log directory.
string | The log directory |
Gets the charset of the application.
string | The charset |
Gets the patterns defining the classes to parse and cache for annotations.
array |
Initializes bundles.
LogicException | if two bundles share a common name |
The extension point similar to the Bundle::build() method.
Use this method to register compiler passes and manipulate the container during the building process.
ContainerBuilder | $container |
Gets the container class.
string | The container class |
Gets the container's base class.
All names except Container must be fully qualified.
string |
Initializes the service container.
The cached version of the service container is used when fresh, otherwise the container is built.
Returns the kernel parameters.
array | An array of kernel parameters |
Builds the service container.
ContainerBuilder | The compiled service container |
RuntimeException |
Prepares the ContainerBuilder before it is compiled.
ContainerBuilder | $container |
Gets a new ContainerBuilder instance used to build the service container.
ContainerBuilder |
Dumps the service container to PHP code in the cache.
ConfigCache | $cache | The config cache |
ContainerBuilder | $container | The service container |
string | $class | The name of the class to generate |
string | $baseClass | The name of the container's base class |
Returns a loader for the container.
ContainerInterface | $container |
DelegatingLoader | The loader |
Removes comments from a PHP source string.
We don't use the PHP php_strip_whitespace() function as we want the content to be readable and well-formatted.
string | $source | A PHP string |
string | The PHP string with the comments removed |
$data |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/HttpKernel/Kernel.html