|
| 1 | +:navigation-title: Application context |
| 2 | +.. include:: /Includes.rst.txt |
| 3 | + |
| 4 | +.. index:: Environment; Configuration; .env ; dotenv |
| 5 | + |
| 6 | +.. _environment-phpconfig: |
| 7 | +.. _environment-configuration: |
| 8 | +.. _application-context: |
| 9 | + |
| 10 | +==================================================== |
| 11 | +TYPO3 Application context: Development or Production |
| 12 | +==================================================== |
| 13 | + |
| 14 | +.. figure:: _ApplicationContext/ApplicationContextInformation.png |
| 15 | + :alt: Screenshot showing the current application context in the "System Information" box |
| 16 | + |
| 17 | + The current application context is displayed on the top-right in the "System Information" box |
| 18 | + |
| 19 | +A TYPO3 instance is often used in different contexts that can adapt to your |
| 20 | +needs. |
| 21 | + |
| 22 | +You can use the application context to differentiate between different |
| 23 | +environments / servers. |
| 24 | + |
| 25 | +There are 3 major application context groups: |
| 26 | + |
| 27 | +`Development` |
| 28 | + To be used during development. Debugging is enabled by default. |
| 29 | +`Production` |
| 30 | + Debugging and deprecation logs are deactivated by default. |
| 31 | +`Testing` |
| 32 | + To be used in automated testing. |
| 33 | + |
| 34 | +You can define arbitrary strings as a subcontext for example `Development/Local` |
| 35 | +or `Production/Stage`. |
| 36 | + |
| 37 | +.. todo: Link to application context in TYPO3 explained, once that chapter is written |
| 38 | +
|
| 39 | +.. contents:: |
| 40 | + |
| 41 | +.. _set-ApplicationContext: |
| 42 | + |
| 43 | +Setting the application context |
| 44 | +=============================== |
| 45 | + |
| 46 | +If the application context is not set it is `Production` by default so that you |
| 47 | +don't have to do anything on the production server. |
| 48 | + |
| 49 | +.. todo: Link to application context in TYPO3 explained, once that chapter is written |
| 50 | +
|
| 51 | +In DDEV you should set the application context to `Development/Local` to enable |
| 52 | +debugging and different site configurations for DDEV and your live server. |
| 53 | + |
| 54 | +Create a file called :file:`docker-compose.context.yaml` in your :path:`.ddev` |
| 55 | +path with the following content: |
| 56 | + |
| 57 | +.. literalinclude:: _ApplicationContext/_docker-compose.context.yaml |
| 58 | + :caption: [project root]/.ddev/docker-compose.context.yaml |
| 59 | + |
| 60 | +Restart DDEV using |
| 61 | + |
| 62 | +.. code-block:: bash |
| 63 | +
|
| 64 | + ddev restart |
| 65 | +
|
| 66 | +.. _development-settings: |
| 67 | + |
| 68 | +Local development |
| 69 | +================= |
| 70 | + |
| 71 | +When you :ref:`installed TYPO3 with DDEV <install>`, DDEV automatically created |
| 72 | +a file called :path:`config/system/additional.php` for you. This file includes |
| 73 | +server settings needed only during development, including: |
| 74 | + |
| 75 | +* A connection to the local database in DDEV |
| 76 | +* Configuration of Mailpit to enable debugging of emails |
| 77 | +* Image magic configuration so that images can be scaled and edited |
| 78 | +* Enabling enhanced error reporting |
| 79 | + |
| 80 | +You should not :ref:`deploy <deployment>` this file to your production server |
| 81 | +but create one just for the production server. |
| 82 | +See section :ref:`production-settings` |
| 83 | + |
| 84 | +.. _production-settings: |
| 85 | + |
| 86 | +Production environment |
| 87 | +====================== |
| 88 | + |
| 89 | +It is not recommended to put credentials into a file that is kept under version |
| 90 | +control. However, many other settings should be kept under version control. |
| 91 | + |
| 92 | +We recommend putting all configuration containing credentials into a special |
| 93 | +file that is not kept under version control and include it in your |
| 94 | +:path:`config/system/additional.php`. |
| 95 | + |
| 96 | +Create a file called :file:`config/system/credentials.php`: |
| 97 | + |
| 98 | +.. literalinclude:: _ApplicationContext/_credentials.php |
| 99 | + :caption: config/system/credentials.php |
| 100 | + |
| 101 | +.. important:: |
| 102 | + Add :file:`config/system/credentials.php` to your `.gitignore` so that it |
| 103 | + is never put under version control. |
| 104 | + |
| 105 | +You can now include this file in your |
| 106 | +:path:`config/system/additional.php`: |
| 107 | + |
| 108 | +.. literalinclude:: _ApplicationContext/_additional.php |
| 109 | + :caption: config/system/additional.php |
| 110 | + |
| 111 | +The following steps are needed for a secure production context: |
| 112 | + |
| 113 | +* :ref:`Generate a unique encryption key <t3coreapi:security-encryption-key-generate>` |
| 114 | + and put it in `$customChanges['SYS']['encryptionKey']` in your |
| 115 | + :file:`config/system/credentials.php`. |
| 116 | +* Choose a new install tool password and put its hash into |
| 117 | + `$customChanges['BE']['installToolPassword']`. |
| 118 | +* Replace the database credentials in the |
| 119 | + `$customChanges['DB']['Connections']['Default']` section with |
| 120 | + database credentials for your server. |
| 121 | + |
| 122 | +Further settings important for security can be made directly in the |
| 123 | +:path:`config/system/additional.php`: |
| 124 | + |
| 125 | +.. literalinclude:: _ApplicationContext/_additional-2.php |
| 126 | + :caption: config/system/additional.php |
| 127 | + |
| 128 | +Please refer to the security guide in getting started to check which settings |
| 129 | +are currently recommended for a secure production environment: |
| 130 | + |
| 131 | +:ref:`Global TYPO3 configuration options <t3coreapi:security-global-typo3-options>` |
| 132 | + |
| 133 | +Suggested configurations might change in future security bulletins. |
| 134 | + |
| 135 | +.. todo: link to chapter about security / security bulletins once it is written. |
| 136 | +
|
| 137 | +You can put any of the suggested changes into the `$customChanges` array of |
| 138 | +your :path:`config/system/additional.php`. |
0 commit comments