Cecil

Platform

Platform utility class.

This class provides methods to detect the platform (OS) on which the application is running, check if it is running from a Phar archive, and open URLs in the system's default browser.

Table of Contents

Constants

OS_LINUX  : int = 3
OS_OSX  : int = 4
OS_UNKNOWN  : int = 1
OS_WIN  : int = 2
OS_FAMILIES  : array<string|int, mixed> = ['Unix' => self::OS_LINUX, 'FreeBSD' => self::O...
PHP_OS values by OS family

Properties

$pharPath  : string

Methods

getOpenBrowserCommand()  : string|null
Returns the command used to open a URL in the system default browser, or null if none is available.
getOS()  : int
Search for system OS in PHP_OS constant.
getPharPath()  : string
Returns the full path on disk to the currently executing Phar archive.
isPhar()  : bool
Running from Phar or not?
isWindows()  : bool
Whether the host machine is running a Windows OS.
openBrowser()  : void
Opens a URL in the system default browser.
commandExists()  : bool
Whether a command is available in the PATH (Unix-like systems only).

Constants

OS_FAMILIES

PHP_OS values by OS family

private array<string|int, mixed> OS_FAMILIES = ['Unix' => self::OS_LINUX, 'FreeBSD' => self::OS_LINUX, 'NetBSD' => self::OS_LINUX, 'OpenBSD' => self::OS_LINUX, 'Linux' => self::OS_LINUX, 'WINNT' => self::OS_WIN, 'WIN32' => self::OS_WIN, 'Windows' => self::OS_WIN, 'CYGWIN_NT' => self::OS_WIN, 'Darwin' => self::OS_OSX]

Properties

$pharPath

protected static string $pharPath

Methods

getOpenBrowserCommand()

Returns the command used to open a URL in the system default browser, or null if none is available.

public static getOpenBrowserCommand(string $url) : string|null
Parameters
$url : string
Return values
string|null

getOS()

Search for system OS in PHP_OS constant.

public static getOS([string|null $os = null ]) : int
Parameters
$os : string|null = null
Return values
int

getPharPath()

Returns the full path on disk to the currently executing Phar archive.

public static getPharPath() : string
Return values
string

isPhar()

Running from Phar or not?

public static isPhar() : bool
Return values
bool

isWindows()

Whether the host machine is running a Windows OS.

public static isWindows() : bool
Return values
bool

openBrowser()

Opens a URL in the system default browser.

public static openBrowser(string $url) : void
Parameters
$url : string

commandExists()

Whether a command is available in the PATH (Unix-like systems only).

private static commandExists(string $command) : bool
Parameters
$command : string
Return values
bool
On this page

Search results