env
Table of Contents
Functions
- cpuCount() : int
- Returns the number of CPUs available (if detectable).
- isCli() : bool
- Checks if the PHP script is running in CLI mode (terminal, cron, Symfony Console…).
- isCliWithFile() : bool
- Checks if the PHP script is running in CLI mode **and** was launched with an actual file.
- isColorTerminal() : bool
- Checks if the CLI supports colors.
- isCron() : bool
- Checks if the script is likely running from a cron job.
- isDebug() : bool
- Checks if PHP is running in debug mode.
- isDocker() : bool
- Checks if PHP is running inside a Docker container.
- isExtensionLoaded() : bool
- Checks if a PHP extension is loaded.
- isInteractive() : bool
- Checks if the script is running in an interactive CLI (php -a or terminal input).
- isLinux() : bool
- Indicates if the OS system is Linux.
- isMac() : bool
- Indicates if the OS system is Mac.
- isOtherOS() : bool
- Checks if the operating system is **not Windows, Mac, or Linux**.
- isWeb() : bool
- Checks if the PHP script is running in a Web server context (not CLI).
- isWindows() : bool
- Indicates if the OS system is Windows.
- phpVersion() : string
- Returns the current PHP version.
Functions
cpuCount()
Returns the number of CPUs available (if detectable).
cpuCount() : int
Tags
Return values
int —The number of CPUs available (if detectable), null otherwise.
isCli()
Checks if the PHP script is running in CLI mode (terminal, cron, Symfony Console…).
isCli() : bool
Returns true if PHP is executed from the command line.
Tags
Return values
bool —true if the script is running in CLI, false otherwise
isCliWithFile()
Checks if the PHP script is running in CLI mode **and** was launched with an actual file.
isCliWithFile() : bool
Returns true if PHP is executed from the command line and $_SERVER['argv'][0] points to an existing file.
Tags
Return values
bool —true if running in CLI with a real script file, false otherwise
isColorTerminal()
Checks if the CLI supports colors.
isColorTerminal() : bool
Tags
Return values
bool —true if the CLI support colors, false otherwise
isCron()
Checks if the script is likely running from a cron job.
isCron() : bool
Tags
Return values
bool —true if likely a cron job, false otherwise
isDebug()
Checks if PHP is running in debug mode.
isDebug() : bool
Tags
Return values
bool —true if PHP is running in debug mode, false otherwise
isDocker()
Checks if PHP is running inside a Docker container.
isDocker() : bool
Tags
Return values
bool —true if running in Docker, false otherwise
isExtensionLoaded()
Checks if a PHP extension is loaded.
isExtensionLoaded(string $ext) : bool
Parameters
- $ext : string
Tags
Return values
bool —true if a PHP extension is loaded, false otherwise
isInteractive()
Checks if the script is running in an interactive CLI (php -a or terminal input).
isInteractive() : bool
Tags
Return values
bool —true if interactive CLI, false otherwise
isLinux()
Indicates if the OS system is Linux.
isLinux() : bool
Tags
Return values
bool —true if running on Linux, false otherwise
isMac()
Indicates if the OS system is Mac.
isMac() : bool
Tags
Return values
bool —true if running on Mac, false otherwise
isOtherOS()
Checks if the operating system is **not Windows, Mac, or Linux**.
isOtherOS() : bool
Tags
Return values
bool —true if the OS is neither Windows, Mac, nor Linux; false otherwise
isWeb()
Checks if the PHP script is running in a Web server context (not CLI).
isWeb() : bool
Returns true if PHP is executed via HTTP (e.g., Slim, Symfony HTTP, WordPress).
Tags
Return values
bool —true if the script is running in a web context, false otherwise
isWindows()
Indicates if the OS system is Windows.
isWindows() : bool
Tags
Return values
bool —true if running on Windows, false otherwise
phpVersion()
Returns the current PHP version.
phpVersion() : string
Tags
Return values
string —The current PHP version.