AppHelper

Type
Class
Namespace
Craft
Inherits
Craft\AppHelper
Since
1.0

Class AppHelper

See also http://craftcms.com

View source (opens new window)

# Public Methods

Method Description
getByteValueFromPhpSizeString() Return a byte value from a size string formatted the way PHP likes it (for example - 64M).
getCraftDownloadUrl() Returns the Craft download URL for a given version.
getEditionName() Returns the name of the given Craft edition.
getEditions() Returns an array of all known Craft editions’ IDs.
getMajorMinorVersion() Returns the major and minor (X.Y) versions from a given version number.
getMajorVersion() Returns the major version from a given version number.
getPhpConfigValueAsBool() Retrieves a boolean PHP config setting and normalizes it to an actual bool.
getPhpConfigValueInBytes() Retrieves a PHP config setting that represents a filesize and normalizes it to bytes.
isPhpDevServer() Returns whether Craft is running on the dev server bundled with PHP 5.4+.
isValidEdition() Returns whether an edition is valid.
isWindows() Returns whether Craft is running on a Windows server.
normalizeVersionNumber() Normalizes a version number based on the same logic as PHP’s version_compare (opens new window) uses internally.

# getByteValueFromPhpSizeString()

DEPRECATED

Deprecated Deprecated in 2.3. Use {@link getPhpConfigValueInBytes()} instead.

Return a byte value from a size string formatted the way PHP likes it (for example - 64M).

View source (opens new window)

Arguments

Returns

integer (opens new window) – The size in bytes.

Signature

public static integer getByteValueFromPhpSizeString ( $value )

# getCraftDownloadUrl()

Returns the Craft download URL for a given version.

View source (opens new window)

Arguments

Returns

string (opens new window) – The download URL

Signature

public static string getCraftDownloadUrl ( $version )

# getEditionName()

Returns the name of the given Craft edition.

View source (opens new window)

Arguments

Returns

string (opens new window) – The edition’s name.

Signature

public static string getEditionName ( $edition )

# getEditions()

Returns an array of all known Craft editions’ IDs.

View source (opens new window)

Returns

array (opens new window) – All the known Craft editions’ IDs.

Signature

public static array getEditions ( )

# getMajorMinorVersion()

Returns the major and minor (X.Y) versions from a given version number.

View source (opens new window)

Arguments

Returns

string (opens new window) – The X.Y parts of the version number

Signature

public static string getMajorMinorVersion ( $version )

# getMajorVersion()

Returns the major version from a given version number.

View source (opens new window)

Arguments

Returns

string (opens new window) – The major version

Signature

public static string getMajorVersion ( $version )

# getPhpConfigValueAsBool()

Retrieves a boolean PHP config setting and normalizes it to an actual bool.

View source (opens new window)

Arguments

Returns

boolean (opens new window) – Whether it is set to the php.ini equivelant of true.

Signature

public static boolean getPhpConfigValueAsBool ( $var )

# getPhpConfigValueInBytes()

Retrieves a PHP config setting that represents a filesize and normalizes it to bytes.

View source (opens new window)

Arguments

Returns

integer (opens new window) – The size in bytes.

Signature

public static integer getPhpConfigValueInBytes ( $var )

# isPhpDevServer()

Returns whether Craft is running on the dev server bundled with PHP 5.4+.

View source (opens new window)

Returns

boolean (opens new window) – Whether Craft is running on the PHP Dev Server.

Signature

public static boolean isPhpDevServer ( )

# isValidEdition()

Returns whether an edition is valid.

View source (opens new window)

Arguments

  • $edition (mixed) – An edition’s ID (or is it?)

Returns

boolean (opens new window) – Whether $edition is a valid edition ID.

Signature

public static boolean isValidEdition ( $edition )

# isWindows()

Returns whether Craft is running on a Windows server.

View source (opens new window)

Returns

boolean (opens new window) – Whether Craft is running on a Windows server or not.

Signature

public static boolean isWindows ( )

# normalizeVersionNumber()

Normalizes a version number based on the same logic as PHP’s version_compare (opens new window) uses internally.

View source (opens new window)

Arguments

Returns

string (opens new window) – The normalized version number

Signature

public static string normalizeVersionNumber ( $version )