\duncan3dc\HelpersEnv

Summary

Methods
Properties
Constants
usePath()
getPath()
path()
realpath()
getHostName()
getMachineName()
getRevision()
getVars()
getVar()
requireVar()
setVar()
getUserAgent()
No public properties found
PATH_DOCUMENT_ROOT
PATH_PHP_SELF
PATH_VENDOR_PARENT
No protected methods found
$path
$vars
N/A
No private methods found
No private properties found
N/A

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

$vars

$vars : array

Type

array — Internal cache of environment variables

Methods

usePath()

usePath(integer|string $path) : void

Set the root path to use in the path methods.

Parameters

integer|string $path

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) : 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

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) : string

Get the revision number from the local git clone data.

Parameters

integer $length

The length of the revision hash to return

Returns

string

getVars()

getVars() : array

Get all defined environment variables.

Returns

array

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

getUserAgent()

getUserAgent() : string

Get the current useragent.

Returns

string