Feature: #110762 - Project-root relative base paths for local storages 

See forge#110762

Description 

A file storage using the Local driver is configured with a base path. Until now, this path was either absolute, or relative to the public web directory when the additional option pathType was set to relative . A directory outside the web root, for example a storage for files that must never be served directly, could therefore only be configured with an absolute path, which ties the configuration to one server.

A relative base path without the pathType option is now resolved against the project path ( \TYPO3\CMS\Core\Core\Environment::getProjectPath() ). In a Composer-based installation this is the directory containing composer.json, so public/fileadmin/ denotes the default fileadmin/ directory and storage/private/ a directory next to config/ and var/. In classic mode the project path and the public path are the same directory, so fileadmin/ keeps its meaning.

Whether such a storage is public is derived as before: a base path below the public directory gets a public URL, any other path needs a baseUri or is served through the file dump controller.

The following rules apply to the basePath option of the local driver:

  • An absolute path is used as is.
  • A relative path with pathType set to relative is resolved against the public path. This is the behaviour of existing storage records and stays unchanged.
  • Any other relative path is resolved against the project path.

The same rules apply when TYPO3 resolves a legacy file path such as fileadmin/images/logo.png to the storage containing it.

Impact 

Local storages can be placed anywhere below the project directory with a relative path that works on every server the project is deployed to. Existing storage records are not affected, as they carry the pathType option.