AppHelper

Type
Class
Namespace
Craft
Inherits
Craft\AppHelper
Since
1.0

Class AppHelper

See also http://craftcms.com

View source

Public Methods

MethodDescription
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 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

Arguments

  • $value (string) – The size string.

Returns

integer – The size in bytes.

Signature

public static integer getByteValueFromPhpSizeString ( $value )

getCraftDownloadUrl()

Returns the Craft download URL for a given version.

View source

Arguments

  • $version (string) – The Craft version

Returns

string – The download URL

Signature

public static string getCraftDownloadUrl ( $version )

getEditionName()

Returns the name of the given Craft edition.

View source

Arguments

  • $edition (integer) – An edition’s ID.

Returns

string – The edition’s name.

Signature

public static string getEditionName ( $edition )

getEditions()

Returns an array of all known Craft editions’ IDs.

View source

Returns

array – 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

Arguments

  • $version (string) – The full version number

Returns

string – 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

Arguments

  • $version (string) – The full version number

Returns

string – 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

Arguments

  • $var (string) – The PHP config setting to retrieve.

Returns

boolean – 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

Arguments

  • $var (string) – The PHP config setting to retrieve.

Returns

integer – 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

Returns

boolean – Whether Craft is running on the PHP Dev Server.

Signature

public static boolean isPhpDevServer ( )

isValidEdition()

Returns whether an edition is valid.

View source

Arguments

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

Returns

boolean – 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

Returns

boolean – 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 uses internally.

View source

Arguments

  • $version (string) – The version number

Returns

string – The normalized version number

Signature

public static string normalizeVersionNumber ( $version )