.. include:: /Includes.rst.txt .. _feature-109409-1774770383: =================================================== Feature: #109409 - Allow configuration of resources =================================================== See :issue:`109409` Description =========== Composer-managed TYPO3 ---------------------- Until now, extensions could only place public resources in their :folder:`Resources/Public` folder. The folder name used to publish these extension resources was a non-configurable MD5 hash. This feature introduces the possibility to configure resources explicitly. This includes additional public folders or files that are published in TYPO3's :folder:`public/_assets` folder, as well as non-public resource paths. TYPO3 classic mode ------------------ In TYPO3 classic mode, there is no visible change for extensions or the `typo3/app` package, since files in extensions are already located within the document root. Restricting resources to the default locations in classic mode therefore mainly follows coding guidelines and keeps compatibility with Composer mode. Configuring extensions ---------------------- Extensions can add :file:`Configuration/Resources.php` to configure resources. This configuration is then added to the following default configuration: .. code-block:: php :caption: EXT:core/Configuration/DefaultPackageResources.php getPackagePath() . 'Resources/Public')) { $resourceDefinitions[] = new PublicResourceDefinition( 'Resources/Public', ); } return $resourceDefinitions; }; This means that when using the system resources API (:ref:`feature-107537-1759136314`), resource identifiers are only allowed to reference files or folders in :folder:`Resources/Private` and, if it exists, :folder:`Resources/Public`. It also means that, by default, :folder:`Resources/Public` in extensions is published in the same way as before this change. Example: Publish an additional public folder ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: php :caption: EXT:my_extension/Configuration/Resources.php getPackageKey() . '/custom/folder/my-components.css', ), ]; }; This publishes the extension file :file:`Build/styles.css` to a folder with a unique hash, which then contains the file :file:`styles.css`. Additionally, :file:`Build/components.css` is published to :file:`_assets/my_extension/custom/folder/my-components.css`. Example: Use a fixed prefix in `_assets` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ By default, TYPO3 generates the public prefix automatically. A fixed prefix can be configured explicitly: .. code-block:: php :caption: EXT:my_extension/Configuration/Resources.php