KernelInterface.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\HttpKernel;
  11. use Symfony\Component\Config\Loader\LoaderInterface;
  12. use Symfony\Component\DependencyInjection\ContainerInterface;
  13. use Symfony\Component\HttpKernel\Bundle\BundleInterface;
  14. /**
  15. * The Kernel is the heart of the Symfony system.
  16. *
  17. * It manages an environment made of application kernel and bundles.
  18. *
  19. * @author Fabien Potencier <fabien@symfony.com>
  20. */
  21. interface KernelInterface extends HttpKernelInterface
  22. {
  23. /**
  24. * Returns an array of bundles to register.
  25. *
  26. * @return iterable<mixed, BundleInterface>
  27. */
  28. public function registerBundles(): iterable;
  29. /**
  30. * Loads the container configuration.
  31. */
  32. public function registerContainerConfiguration(LoaderInterface $loader): void;
  33. /**
  34. * Boots the current kernel.
  35. */
  36. public function boot(): void;
  37. /**
  38. * Shutdowns the kernel.
  39. *
  40. * This method is mainly useful when doing functional testing.
  41. */
  42. public function shutdown(): void;
  43. /**
  44. * Gets the registered bundle instances.
  45. *
  46. * @return array<string, BundleInterface>
  47. */
  48. public function getBundles(): array;
  49. /**
  50. * Returns a bundle.
  51. *
  52. * @throws \InvalidArgumentException when the bundle is not enabled
  53. */
  54. public function getBundle(string $name): BundleInterface;
  55. /**
  56. * Returns the file path for a given bundle resource.
  57. *
  58. * A Resource can be a file or a directory.
  59. *
  60. * The resource name must follow the following pattern:
  61. *
  62. * "@BundleName/path/to/a/file.something"
  63. *
  64. * where BundleName is the name of the bundle
  65. * and the remaining part is the relative path in the bundle.
  66. *
  67. * @throws \InvalidArgumentException if the file cannot be found or the name is not valid
  68. * @throws \RuntimeException if the name contains invalid/unsafe characters
  69. */
  70. public function locateResource(string $name): string;
  71. /**
  72. * Gets the environment.
  73. */
  74. public function getEnvironment(): string;
  75. /**
  76. * Checks if debug mode is enabled.
  77. */
  78. public function isDebug(): bool;
  79. /**
  80. * Gets the project dir (path of the project's composer file).
  81. */
  82. public function getProjectDir(): string;
  83. /**
  84. * Gets the current container.
  85. */
  86. public function getContainer(): ContainerInterface;
  87. /**
  88. * Gets the request start time (not available if debug is disabled).
  89. */
  90. public function getStartTime(): float;
  91. /**
  92. * Gets the cache directory.
  93. *
  94. * This directory should be used for caches that are written at runtime.
  95. * For caches and artifacts that can be warmed at compile-time and deployed as read-only,
  96. * use the "build directory" returned by the {@see getBuildDir()} method.
  97. */
  98. public function getCacheDir(): string;
  99. /**
  100. * Returns the build directory.
  101. *
  102. * This directory should be used to store build artifacts, and can be read-only at runtime.
  103. * System caches written at runtime should be stored in the "cache directory" ({@see KernelInterface::getCacheDir()}).
  104. * Application caches that are shared between all front-end servers should be stored
  105. * in the "share directory" ({@see KernelInterface::getShareDir()}).
  106. */
  107. public function getBuildDir(): string;
  108. /**
  109. * Returns the share directory.
  110. *
  111. * This directory should be used to store data that is shared between all front-end servers.
  112. * This typically fits application caches.
  113. */
  114. public function getShareDir(): ?string;
  115. /**
  116. * Gets the log directory.
  117. */
  118. public function getLogDir(): string;
  119. /**
  120. * Gets the charset of the application.
  121. */
  122. public function getCharset(): string;
  123. }