-
Notifications
You must be signed in to change notification settings - Fork 0
Predefined constants and global variables
By default you will have access to various variables from the PHP super global $_SERVER but the Tsama framework have a few static methods that can also return not just the global variables but also certain logic applied to the super global arrays and the result thereof as well as the arrays for the Tsama global variables such as $_WEB_CONFIG and $_DB_CONFIG and $_THEME_CONFIG.
By default you should be able to access the Server class via the Tsama namespace. Example:
<?php
namespace Tsama;
$basedir = Server::GetFullBaseDir();
?>
or simply
$basedir = Tsama\Server::GetFullBaseDir();
The following methods are available:
Returns either http
or https
depending on the protocol enabled for your website.
NB: This differs from the super global $_SERVER['SERVER_PROTOCOL']
Returns the base directory of your website installation.
Returns the super global $_SERVER['DOCUMENT_ROOT']
Returns the super global $_SERVER['SERVER_NAME']
Returns the super global $_SERVER['SERVER_PORT']
Returns the subdirectory the framework is installed in if different than the root of your website.
This is Tsama specific
Returns the base url of your website, ending in a / . Example: http://tsama.local/
This is Tsama specific
Returns exactly the same value as Server::GetBaseDir()
This is Tsama specific
Returns a formatted value of the subdirectory. Example: /subdir/
This is Tsama specific
Returns an array with the current url route.
Example: http://tsama.local/page/carousel
will return array( 'page', 'carousel' )
This is Tsama specific
Returns the current service being called.
NB: The service is always first item in the route.
Example: http://tsama.local/page/carousel
will return page
as the service.
This is Tsama specific
Returns the $_WEB_CONFIG array or a specific config within the array as an item of an array.
Example:
$siteConf = Server::GetWebsiteConfig();
$siteName = $siteConf["NAME"];
or
$siteConf = Server::GetWebsiteConfig("NAME");
$siteName = $siteConf["NAME"];
This is Tsama specific
Returns the $_DB_CONFIG array or a specific config within the array as an item of an array.
Example:
$dbConf = Server::GetDatabaseConfig();
$dbDriver = $dbConf ["Driver"];
or
$dbConf = Server::GetDatabaseConfig("Driver");
$dbDriver = $dbConf ["Driver"];
This is Tsama specific
Returns the $_THEME_CONFIG array or a specific config within the array as an item of an array. The array will contain values from the default site theme configured in $_WEB_CONFIG.
Example:
$themeConf= Server::GetThemeConfig();
$themeConf= $dbConf ["BOOTSTRAP_MODE"];
or
$themeConf = Server::GetThemeConfig("BOOTSTRAP_MODE");
$themeConf = $dbConf ["BOOTSTRAP_MODE"];
Returns the Tsama version from $_TSAMA_VERSION
Example:
$version = Server::GetTsamaVersion();
This is Tsama specific
NEXT » Adding content «