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\Config\Loader\LoaderInterface;
15 use Symfony\Component\DependencyInjection\ContainerInterface;
16 use Symfony\Component\HttpKernel\Bundle\BundleInterface;
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 iterable|BundleInterface[] An iterable of bundle instances
32 public function registerBundles();
35 * Loads the container configuration.
37 public function registerContainerConfiguration(LoaderInterface $loader);
40 * Boots the current kernel.
42 public function boot();
45 * Shutdowns the kernel.
47 * This method is mainly useful when doing functional testing.
49 public function shutdown();
52 * Gets the registered bundle instances.
54 * @return BundleInterface[] An array of registered bundle instances
56 public function getBundles();
59 * Returns a bundle and optionally its descendants by its name.
61 * The second argument is deprecated as of 3.4 and will be removed in 4.0. This method
62 * will always return an instance of BundleInterface in 4.0.
64 * @param string $name Bundle name
65 * @param bool $first Whether to return the first bundle only or together with its descendants
67 * @return BundleInterface|BundleInterface[] A BundleInterface instance or an array of BundleInterface instances if $first is false
69 * @throws \InvalidArgumentException when the bundle is not enabled
71 public function getBundle($name, $first = true);
74 * Returns the file path for a given resource.
76 * A Resource can be a file or a directory.
78 * The resource name must follow the following pattern:
80 * "@BundleName/path/to/a/file.something"
82 * where BundleName is the name of the bundle
83 * and the remaining part is the relative path in the bundle.
85 * If $dir is passed, and the first segment of the path is "Resources",
86 * this method will look for a file named:
88 * $dir/<BundleName>/path/without/Resources
90 * before looking in the bundle resource folder.
92 * @param string $name A resource name to locate
93 * @param string $dir A directory where to look for the resource first
94 * @param bool $first Whether to return the first path or paths for all matching bundles
96 * @return string|array The absolute path of the resource or an array if $first is false
98 * @throws \InvalidArgumentException if the file cannot be found or the name is not valid
99 * @throws \RuntimeException if the name contains invalid/unsafe characters
101 public function locateResource($name, $dir = null, $first = true);
104 * Gets the name of the kernel.
106 * @return string The kernel name
108 public function getName();
111 * Gets the environment.
113 * @return string The current environment
115 public function getEnvironment();
118 * Checks if debug mode is enabled.
120 * @return bool true if debug mode is enabled, false otherwise
122 public function isDebug();
125 * Gets the application root dir (path of the project's Kernel class).
127 * @return string The Kernel root dir
129 public function getRootDir();
132 * Gets the current container.
134 * @return ContainerInterface|null A ContainerInterface instance or null when the Kernel is shutdown
136 public function getContainer();
139 * Gets the request start time (not available if debug is disabled).
141 * @return int The request start timestamp
143 public function getStartTime();
146 * Gets the cache directory.
148 * @return string The cache directory
150 public function getCacheDir();
153 * Gets the log directory.
155 * @return string The log directory
157 public function getLogDir();
160 * Gets the charset of the application.
162 * @return string The charset
164 public function getCharset();