|
| 1 | +.. index:: |
| 2 | + single: Configuration reference; Kernel class |
| 3 | + |
| 4 | +Configuring in the Kernel (e.g. AppKernel) |
| 5 | +========================================== |
| 6 | + |
| 7 | +Some configuration can be done on the kernel class itself (usually called |
| 8 | +``app/AppKernel.php``). You can do this by overriding specific methods in |
| 9 | +the parent :class:`Symfony\\Component\\HttpKernel\\Kernel` class. |
| 10 | + |
| 11 | +Configuration |
| 12 | +------------- |
| 13 | + |
| 14 | +* `Kernel Name`_ |
| 15 | +* `Root Directory`_ |
| 16 | +* `Cache Directory`_ |
| 17 | +* `Log Directory`_ |
| 18 | + |
| 19 | +Kernel Name |
| 20 | +~~~~~~~~~~~ |
| 21 | + |
| 22 | +**type**: ``string`` **default**: ``app`` (i.e. the directory name holding the kernel class) |
| 23 | + |
| 24 | +To change this setting, override the :method:`Symfony\\Component\\HttpKernel\\Kernel::getName` |
| 25 | +method. Alternatively, move your kernel into a different directory. For example, |
| 26 | +if you moved the kernel into a ``foo`` directory (instead of ``app``), the |
| 27 | +kernel name will be ``foo``. |
| 28 | + |
| 29 | +The name of the kernel isn't usually directly important - it's used in the |
| 30 | +generation of cache files. If you have an application with multiple kernels, |
| 31 | +the easiest way to make each have a unique name is to duplicate the ``app`` |
| 32 | +directory and rename it to something else (e.g. ``foo``). |
| 33 | + |
| 34 | +Root Directory |
| 35 | +~~~~~~~~~~~~~~ |
| 36 | + |
| 37 | +**type**: ``string`` **default**: the directory of ``AppKernel`` |
| 38 | + |
| 39 | +This returns the root directory of your kernel. If you use the Symfony Standard |
| 40 | +edition, the root directory refers to the ``app`` directory. |
| 41 | + |
| 42 | +To change this setting, override the |
| 43 | +:method:`Symfony\\Component\\HttpKernel\\Kernel::getRootDir` method:: |
| 44 | + |
| 45 | + // app/AppKernel.php |
| 46 | + |
| 47 | + // ... |
| 48 | + class AppKernel extends Kernel |
| 49 | + { |
| 50 | + // ... |
| 51 | + |
| 52 | + public function getRootDir() |
| 53 | + { |
| 54 | + return realpath(parent::getRootDir().'/../'); |
| 55 | + } |
| 56 | + } |
| 57 | + |
| 58 | +Cache Directory |
| 59 | +~~~~~~~~~~~~~~~ |
| 60 | + |
| 61 | +**type**: ``string`` **default**: ``$this->rootDir/cache/$this->environment`` |
| 62 | + |
| 63 | +This returns the path to the cache directory. To change it, override the |
| 64 | +:method:`Symfony\\Component\\HttpKernel\\Kernel::getCacheDir` method. Read |
| 65 | +":ref:`override-cache-dir`" for more information. |
| 66 | + |
| 67 | +Log Directory |
| 68 | +~~~~~~~~~~~~~ |
| 69 | + |
| 70 | +**type**: ``string`` **default**: ``$this->rootDir/logs`` |
| 71 | + |
| 72 | +This returns the path to the log directory. To change it, override the |
| 73 | +:method:`Symfony\\Component\\HttpKernel\\Kernel::getLogDir` method. Read |
| 74 | +":ref:`override-logs-dir`" for more information. |
0 commit comments