URL
URL
Generate a URL relative to the application.
class URL extends \Hazaar\HTTP\URLExtends: Hazaar\HTTP\URL
This is the base method for generating URLs in your application. URLs generated directly from here are relative to the application base path.
Parameters are dynamic and depend on what you are trying to generate.
For examples see Generating URLs in the Hazaar documentation.
Properties
baseURL
public string $baseURLType: string
aliases
public array $aliasesType: array
Methods
__construct
Constructs a new URL object relative to the application base path.
public __construct(array|string|\stdClass $args): voidAccepts a variable number of arguments, which can be path segments (as strings), arrays or stdClass objects for query parameters, or strings containing query parameters.
Examples: new URL('controller', 'action', ['id' => 1]);new URL('controller/action?id=1&foo=bar');
Parameters
| Parameter | Type | Description |
|---|---|---|
$args | array | string |
build
Creates a new instance of the URL class using the provided URL string.
public build(string $url): selfReturns: self
Parameters
| Parameter | Type | Description |
|---|---|---|
$url | string | The URL string to initialize the instance with. Defaults to an empty string. |
initialise
Initializes the URL class with the provided configuration.
public initialise(array $config): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$config | array | the configuration object containing the base URL, rewrite URL, and default controller |
resolveConnectionDetails
Resolves and constructs the base connection URL using server variables.
private resolveConnectionDetails(): stringReturns: string
Determines the protocol (http/https), host (with port if non-standard), and appends the application path.
X-Forwarded-Scheme, X-Forwarded-Host and X-Forwarded-Port are only used when the request came from a trusted proxy (see Hazaar\Application\Request::isTrustedProxy), and each one is validated before use. A missing or invalid value falls back to the non-forwarded one.
validForwardedScheme
Return a forwarded scheme if it's http or https, otherwise null.
private validForwardedScheme(mixed $scheme): ?stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$scheme | mixed |
validForwardedHost
Return a forwarded host if it's a valid hostname or IP literal (with an optional port), otherwise null.
private validForwardedHost(mixed $host): ?stringReturns: string
Parameters
| Parameter | Type | Description |
|---|---|---|
$host | mixed |
validForwardedPort
Return a forwarded port if it's a number from 1 to 65535, otherwise null.
private validForwardedPort(mixed $port): ?intReturns: int
Parameters
| Parameter | Type | Description |
|---|---|---|
$port | mixed |
Generated by Hazaar API Doc Generator on Thu, 22 Oct 2026 05:05:30 +0000