-
-
Notifications
You must be signed in to change notification settings - Fork 6
URIs
A URI (Universal Resource Identifier) is a sequence of characters that identify the World Wide Web request being made. Sometimes referred to as a URL (Universal Resource Locator) or URN (Universal Resource Name), with extremely subtle differences, we shall use the term URI for consistency with PHP's internal naming conventions.
A simple URI https://www.example.com/colour/red
is made up of the following parts:
-
https
- the URI scheme / protocol being used to make the request -
www.example.com
- the host (otherwise referred to as the hostname) -
/colour/red
- the path
A complex URI https://henry:[email protected]:8301/colour/red?sort=price&filter=new#options
is made up of the following parts:
-
https
- the URI scheme / protocol being used to make the request -
henry:s3cr3t
- the user info -
www.example.com
- the host (otherwise referred to as the hostname) -
8301
- the port -
/colour/red
- the path -
sort=price&filter=new
- the query or querystring -
option
- the fragment
Throughout PHP.Gt, wherever a URI is referenced, an object that implements PSR-7's UriInterface
is used.
In WebEngine applications, all superglobals are protected, which means the $_SERVER
superglobal is not available. Instead, the values of $_SERVER
are exposed through the Server
class (part of PHP.Gt/Http) and encapsulated within your Page Logic.
From within any Page Logic class, you can obtain the current requested URI using the getRequestUri
function of the Server
object, as follows:
public function checkCurrentURI() {
$uri = $this->server->getRequestUri();
$host = $uri->getHost();
$path = $uri->getPath();
$this->doSomethingWithUriParts($host, $path);
}
- Request-response lifecycle
- Running your application
- Project layout
- Application architecture
- Web servers
- URIs
- Page view
- Dynamic URIs and pages
- Headers and footers
- Page logic
- Protected globals
- User input
- Cookies
- Sessions
- DOM manipulation
- Custom HTML components
- DOM templates
- Binding data to the DOM
- Database
- Client side assets
- API Webservices
- Security
- Configuration
- Build system
- Coding styleguide