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