4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpKernel;
14 use Symfony\Component\DependencyInjection\ContainerInterface;
15 use Symfony\Component\HttpKernel\Bundle\BundleInterface;
16 use Symfony\Component\Config\Loader\LoaderInterface;
19 * The Kernel is the heart of the Symfony system.
21 * It manages an environment made of bundles.
23 * @author Fabien Potencier <fabien@symfony.com>
25 interface KernelInterface extends HttpKernelInterface, \Serializable
28 * Returns an array of bundles to register.
30 * @return BundleInterface[] An array of bundle instances
32 public function registerBundles();
35 * Loads the container configuration.
37 * @param LoaderInterface $loader A LoaderInterface instance
39 public function registerContainerConfiguration(LoaderInterface $loader);
42 * Boots the current kernel.
44 public function boot();
47 * Shutdowns the kernel.
49 * This method is mainly useful when doing functional testing.
51 public function shutdown();
54 * Gets the registered bundle instances.
56 * @return BundleInterface[] An array of registered bundle instances
58 public function getBundles();
61 * Checks if a given class name belongs to an active bundle.
63 * @param string $class A class name
65 * @return bool true if the class belongs to an active bundle, false otherwise
67 * @deprecated since version 2.6, to be removed in 3.0.
69 public function isClassInActiveBundle($class);
72 * Returns a bundle and optionally its descendants by its name.
74 * @param string $name Bundle name
75 * @param bool $first Whether to return the first bundle only or together with its descendants
77 * @return BundleInterface|BundleInterface[] A BundleInterface instance or an array of BundleInterface instances if $first is false
79 * @throws \InvalidArgumentException when the bundle is not enabled
81 public function getBundle($name, $first = true);
84 * Returns the file path for a given resource.
86 * A Resource can be a file or a directory.
88 * The resource name must follow the following pattern:
90 * "@BundleName/path/to/a/file.something"
92 * where BundleName is the name of the bundle
93 * and the remaining part is the relative path in the bundle.
95 * If $dir is passed, and the first segment of the path is "Resources",
96 * this method will look for a file named:
98 * $dir/<BundleName>/path/without/Resources
100 * before looking in the bundle resource folder.
102 * @param string $name A resource name to locate
103 * @param string $dir A directory where to look for the resource first
104 * @param bool $first Whether to return the first path or paths for all matching bundles
106 * @return string|array The absolute path of the resource or an array if $first is false
108 * @throws \InvalidArgumentException if the file cannot be found or the name is not valid
109 * @throws \RuntimeException if the name contains invalid/unsafe characters
111 public function locateResource($name, $dir = null, $first = true);
114 * Gets the name of the kernel.
116 * @return string The kernel name
118 public function getName();
121 * Gets the environment.
123 * @return string The current environment
125 public function getEnvironment();
128 * Checks if debug mode is enabled.
130 * @return bool true if debug mode is enabled, false otherwise
132 public function isDebug();
135 * Gets the application root dir.
137 * @return string The application root dir
139 public function getRootDir();
142 * Gets the current container.
144 * @return ContainerInterface A ContainerInterface instance
146 public function getContainer();
149 * Gets the request start time (not available if debug is disabled).
151 * @return int The request start timestamp
153 public function getStartTime();
156 * Gets the cache directory.
158 * @return string The cache directory
160 public function getCacheDir();
163 * Gets the log directory.
165 * @return string The log directory
167 public function getLogDir();
170 * Gets the charset of the application.
172 * @return string The charset
174 public function getCharset();