Feature: #84153 - Introduce a generic Environment class
See forge#84153
Description
A new base API class
\TYPO3\ has been added. This class contains application-wide
information related to paths and PHP internals, which were previously exposed via PHP constants.
This Environment class comes with a new possibility, to have a config and var folder outside of the document root
(known as PATH_). When the environment variable
TYPO3_ is set, which defines the project root
folder, the new config and var folders outside of the document root are used for installation-wide configuration and
volatile files.
The following static API methods are exposed within the Environment class:
Environment::- defines whether TYPO3 runs on a CLI context or HTTP contextis Cli () Environment::- returns the ApplicationContext object that encapsulatesget Application Context () TYPO3_CONTEXT Environment::- defines whether TYPO3 was installed via composeris Composer Mode () Environment::- returns the absolute path to the root-level folder without the trailing slashget Project Path () Environment::- returns the absolute path to the publically accessible folder (previously known as PATH_site) without the trailing slashget Public Path () Environment::- returns the absolute path to the folder where non-public semi-persistent files can be stored. For regular projects, this is known as PATH_site/typo3temp/varget Var Path () Environment::- returns the absolute path to the folder where (writeable) configuration is stored. For regular projects, this is known as PATH_site/typo3confget Config Path () Environment::- the absolute path and filename to the currently executed PHP scriptget Current Script () Environment::- whether TYPO3 runs on a windows serveris Windows () Environment::- whether TYPO3 runs on a unix serveris Unix ()
Impact
You should not rely on the PHP constants anymore, but rather use the Environment class to resolve paths:
PATH_site PATH_typo3conf PATH_site . 'typo3temp/ var/' TYPO3_OS TYPO3_REQUESTTYPE_ CLI PATH_this Script