Class: extra_server_vars
List of extra server variables introduced by the extra_server_vars.php file.
Edited: 2021-03-07 19:26
There is a number of extra _SERVER variables introduced to solve both common and uncommon problems, these are loaded by the extra_server_vars class, inside of extra_server_vars.php, and before the superglobals.php file has been loaded.
If you are using the superglobals class outside of the CMS, then you will need to load the extra_server_vars before loading the superglobals class.
From inside an app, the variables may be accessed like this:
$this->sg->get_SERVER('base_path');
// Or:
$this->G->get_SERVER('base_path');
Usage
This class is instantiated automatically by the CMS.
When or if this class is used from outside of the main code, it may be instantiated before the superglobals class, possibly from the composition root (I.e. Index.php).
Once the class is instantiated, the extra server variables will automatically be made available in the $_SERVER superglobal. This is done in the constructor, so there is no need do anything after instantiating a extra_server_vars object.
How exactly to access them will depend on where you are accessing them from, and also, sometimes there might be multiple ways to access superglobals; just keep in mind that superglobals should never be accessed directly.
List of server variables
Below is a list of these extra variables:
-
base_path
The base path where the CMS is located, including "/" at the end.
-
request_time
The time of the request. Should be used everywhere where this is needed, since calling time() later might be inaccurate.
-
request_protocol
The protocol used by the client. I.e. "https" or "http".
-
full_request_uri
The full public URL of the request, including URL parameters.
-
request_path
The path (public URL) of the request, without URL parameters and without the domain name.
-
query_string
The query string part of the URL.
-
work_path
The current public URL of the last URL segment, with the file- or document name cut off. I.e. /images/category/
Tell us what you think: