Constants

PATH_DOCUMENT_ROOT

PATH_DOCUMENT_ROOT

For use with usePath() - Represents the apache document root

PATH_PHP_SELF

PATH_PHP_SELF

For use with usePath() - Represents the directory that the PHP_SELF filename is in

PATH_VENDOR_PARENT

PATH_VENDOR_PARENT

For use with usePath() - Represents the parent of the vendor directory (commonly the project root)

Properties

$path

$path : string

Type

string — The root path to use.

$hostname

$hostname : string

Type

string — The name of the current domain running.

$machine

$machine : string

Type

string — The name of the current server running.

$revision

$revision : string

Type

string — The current git version of the codebase running.

Methods

usePath()

usePath(integer|string  $argument) : void

Set the root path to use in the path methods.

Parameters

integer|string $argument

Either one of the PATH class constants or an actual path to a directory that exists, and is readable

getPath()

getPath() : string

Get the root path, by default this is the parent directory of the composer vender directory.

Returns

string

path()

path(  $append, integer|string  $use = null) : string

Get an absolute path for the specified relative path (relative to the currently used internal root path).

Parameters

$append
integer|string $use

Either one of the PATH class constants or an actual path to a directory that exists, and is readable

Returns

string

setEnvironment()

setEnvironment(\duncan3dc\Env\EnvironmentInterface  $environment) : void

Set the instance to use for environment variables/

Parameters

\duncan3dc\Env\EnvironmentInterface $environment

The instance to use.

getVar()

getVar(string  $var) : mixed

Get a specific environment variable, or null if it doesn't exist.

Parameters

string $var

The name of the variable to retrieve

Returns

mixed

requireVar()

requireVar(string  $var) : mixed

Get a specific environment variable, throw an exception if it doesn't exist.

Parameters

string $var

The name of the variable to retrieve

Returns

mixed

setVar()

setVar(string  $var, string|integer|boolean  $value) : void

Override an environment variable.

Parameters

string $var

The name of the variable to set

string|integer|boolean $value

The value of the environment variable

realpath()

realpath(string  $append) : string

Get an absolute path for the specified relative path, convert symlinks to a canonical path, and check the path exists.

This method is very similar to path() except the result is then run through php's standard realpath() function.

Parameters

string $append

The relative path to append to the root path

Returns

string

getHostName()

getHostName() : string

Get the current hostname from apache if this is mod_php otherwise the server's hostname.

Returns

string

getMachineName()

getMachineName() : string

Get the current hostname of the machine.

Returns

string

getRevision()

getRevision(integer  $length = 10) : string|void

Get the revision number from the local git clone data.

Parameters

integer $length

The length of the revision hash to return

Returns

string|void

getUserAgent()

getUserAgent() : string

Get the current useragent.

Returns

string