Welcome to FrostSW!

FrostMVC PHP Framework

Documentation   |   Version

Site

FrostMVC\Site

use FrostMVC\Site;

Application configuration and bootstrap context.

Holds site-level settings (name, URL, email, environment), initialises the Twig view layer, and manages multiple named site instances for multi-site setups. The active instance is stored in Site::$instance and is accessible globally via the framework's getInstance() helper.

Properties

PropertyTypeDescription
$NAMESPACE mixed
$APPPATH mixed
$BASEPATH mixed
$RESOURCEPATH mixed
$from mixed
$extra mixed
Site::$instance mixed
Site::$instances mixed
$twig mixed
$require mixed
$loader mixed

Methods

->__construct() —
::addInstance()

Creates or updates a named Site instance from a configuration array. Accepts keys: name, url, contact, email, address, mobile, facebook, FBID, twitter, namespace, environment, timezone, libraries[], twig{}.

->getAddress() —
::getClientIP()

Returns the client IP address, walking common proxy headers in priority order. Note: HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR can be spoofed by clients. Validate the result against a trusted-proxy allowlist for security-sensitive use cases.

->getContact() —
::getCurrentURL()

Returns the full current request URL (protocol + host + path + query string). When $fullPath is false, only the protocol and host are returned.

->getEmail() —
->getEnvironment()

Returns the current environment string, e.g. 'Development' or 'Production'. Twig debug mode is enabled when this equals 'Development'.

->getFacebook() —
->getFBID() —
->getHomeSite() —
::getInstance()

Returns the named Site instance, creating it if necessary.

->getMobile() —
->getMultiSiteMode() —
->getName() —
->getNamespace() —
::getProtocol()

Detects the current request protocol (http or https). Respects Cloudflare's CF-Visitor header and reverse-proxy X-Forwarded-Proto.

::getQueryParams()

Parses query parameters and path segments from a URL.

->getTwitter() —
->getURL() —
->getVersion() —
->setAddress() —
->setContact() —
->setEmail() —
->setEnvironment() —
->setFacebook() —
->setFBID() —
->setHomeSite() —
->setMobile() —
->setMultiSiteMode() —
->setName() —
->setNamespace() —
->setTwitter() —
->setURL() —
->setVersion() —

__construct()

$site->__construct($siteName = '')

No description yet.

Parameters

$siteName string

Optional name for this site instance.

Default: ''

addInstance() static

Site::addInstance($config): FrostMVC\Site

Creates or updates a named Site instance from a configuration array. Accepts keys: name, url, contact, email, address, mobile, facebook, FBID, twitter, namespace, environment, timezone, libraries[], twig{}.

Parameters

$config array

Associative configuration array.

Returns

Site

getAddress()

$site->getAddress()

No description yet.

Returns

string Physical address.

getClientIP() static

Site::getClientIP()

Returns the client IP address, walking common proxy headers in priority order. Note: HTTP_CLIENT_IP and HTTP_X_FORWARDED_FOR can be spoofed by clients. Validate the result against a trusted-proxy allowlist for security-sensitive use cases.

Returns

string IP address string, or 'UNKNOWN' when no header is present.

getContact()

$site->getContact()

No description yet.

Returns

string Primary contact number.

getCurrentURL() static

Site::getCurrentURL($fullPath = true)

Returns the full current request URL (protocol + host + path + query string). When $fullPath is false, only the protocol and host are returned.

Parameters

$fullPath bool

When true (default), includes the request URI.

Default: true

Returns

string

getEmail()

$site->getEmail()

No description yet.

Returns

string Contact email address.

getEnvironment()

$site->getEnvironment()

Returns the current environment string, e.g. 'Development' or 'Production'. Twig debug mode is enabled when this equals 'Development'.

Returns

string

getFacebook()

$site->getFacebook()

No description yet.

Returns

string Facebook page URL or slug.

getFBID()

$site->getFBID()

No description yet.

Returns

string Facebook App ID.

getHomeSite()

$site->getHomeSite()

No description yet.

Returns

string Root/homepage URL used for cross-site redirects.

getInstance() static

Site::getInstance($siteName): FrostMVC\Site

Returns the named Site instance, creating it if necessary.

Parameters

$siteName string

The site instance name.

Returns

Site

getMobile()

$site->getMobile()

No description yet.

Returns

string Mobile number.

getMultiSiteMode()

$site->getMultiSiteMode()

No description yet.

Returns

string Multi-site routing mode: 'subfolder' or 'subdomain'.

getName()

$site->getName()

No description yet.

Returns

string Site display name.

getNamespace()

$site->getNamespace()

No description yet.

Returns

string

getProtocol() static

Site::getProtocol()

Detects the current request protocol (http or https). Respects Cloudflare's CF-Visitor header and reverse-proxy X-Forwarded-Proto.

Returns

string 'http' or 'https'.

getQueryParams() static

Site::getQueryParams($url, $parameter = false, $defaultValue = false)

Parses query parameters and path segments from a URL.

  • When $parameter is a string, returns that query string value (or $defaultValue).
  • When $parameter is true, returns the URL path as an array of segments.
  • When $parameter is false, merges query params into $_GET and returns the full params array.
  • When $url is true, the current request URL is used.

Parameters

$url string|true

The URL to parse, or true for the current request URL.

$parameter string|true|false

Query parameter name, true for path segments, or false to populate $_GET.

Default: false
$defaultValue mixed

Returned when a named $parameter is not present in the URL.

Default: false

Returns

mixed

getTwitter()

$site->getTwitter()

No description yet.

Returns

string Twitter handle.

getURL()

$site->getURL()

No description yet.

Returns

string Canonical base URL of this site (no trailing slash).

getVersion()

$site->getVersion()

No description yet.

Returns

string Plugin/app version (e.g. '1.0.0').

setAddress()

$site->setAddress($newval)

No description yet.

Parameters

$newval string

setContact()

$site->setContact($newval)

No description yet.

Parameters

$newval string

setEmail()

$site->setEmail($newval)

No description yet.

Parameters

$newval string

setEnvironment()

$site->setEnvironment($newval)

No description yet.

Parameters

$newval string

Environment name. Ignored when $newval is true.

setFacebook()

$site->setFacebook($newval)

No description yet.

Parameters

$newval string

Facebook page URL or slug.

setFBID()

$site->setFBID($newval)

No description yet.

Parameters

$newval string

Facebook App ID.

setHomeSite()

$site->setHomeSite($newval)

No description yet.

Parameters

$newval string

setMobile()

$site->setMobile($newval)

No description yet.

Parameters

$newval string

setMultiSiteMode()

$site->setMultiSiteMode($newval)

No description yet.

Parameters

$newval string

Multi-site routing mode: 'subfolder' or 'subdomain'.

setName()

$site->setName($newSiteName)

No description yet.

Parameters

$newSiteName string

setNamespace()

$site->setNamespace($namespace)

No description yet.

Parameters

$namespace string

PHP namespace prefix used when autoloading application classes.

setTwitter()

$site->setTwitter($newval)

No description yet.

Parameters

$newval string

Twitter handle.

setURL()

$site->setURL($newval)

No description yet.

Parameters

$newval string

Canonical base URL.

setVersion()

$site->setVersion($newval)

No description yet.

Parameters

$newval string

Plugin/app version.

Generated from core/classes/Site.php (FrostMVC ).