Uri
class Uri implements Htmlable, Responsable (View source)
Traits
Properties
protected | $uri | The URI instance. |
|
static protected | $urlGeneratorResolver | The URL generator resolver. |
Methods
Apply the callback if the given "value" is (or resolves to) truthy.
Apply the callback if the given "value" is (or resolves to) falsy.
Call the given Closure with this instance then return the instance.
Create a new parsed URI instance.
Get a URI instance for a named route.
Get the URI's scheme.
Get the user from the URI.
Get the password from the URI.
Get the URI's host.
Get the URI's port.
Get the URI's path.
Get the URI's query string.
Get the URI's fragment.
Specify the scheme of the URI.
Specify the user and password for the URI.
Merge new query parameters into the URI if they are not already in the query string.
Push a value onto the end of a query string parameter that is a list.
Remove the given query parameters from the URI.
Specify new query parameters for the URI.
Specify the fragment of the URI.
Create a redirect HTTP response for the given URI.
Get content as a string of HTML.
Get the decoded string representation of the URI.
Get the string representation of the URI.
Determine if the URI is currently an empty string.
Get the underlying URI instance.
Get the string representation of the URI.
Details
$this|TWhenReturnType
when($value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
$this|TUnlessReturnType
unless($value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
tap($callback = null)
Call the given Closure with this instance then return the instance.
__construct(UriInterface|Stringable|string $uri = '')
Create a new parsed URI instance.
static Uri
of(UriInterface|Stringable|string $uri = '')
Create a new URI instance.
static Uri
to(string $path)
Get a URI instance of an absolute URL for the given path.
static Uri
route(BackedEnum|string $name, mixed $parameters = [], bool $absolute = true)
Get a URI instance for a named route.
string|null
scheme()
Get the URI's scheme.
string|null
user(bool $withPassword = false)
Get the user from the URI.
string|null
password()
Get the password from the URI.
string|null
host()
Get the URI's host.
int|null
port()
Get the URI's port.
string|null
path()
Get the URI's path.
Empty or missing paths are returned as a single "/".
UriQueryString
query()
Get the URI's query string.
string|null
fragment()
Get the URI's fragment.
Uri
withScheme(Stringable|string $scheme)
Specify the scheme of the URI.
Uri
withUser(Stringable|string|null $user, Stringable|string|null $password = null)
Specify the user and password for the URI.
Uri
withHost(Stringable|string $host)
Specify the host of the URI.
Uri
withPort(int|null $port)
Specify the port of the URI.
Uri
withPath(Stringable|string $path)
Specify the path of the URI.
Uri
withQuery(array $query, bool $merge = true)
Merge new query parameters into the URI.
Uri
withQueryIfMissing(array $query)
Merge new query parameters into the URI if they are not already in the query string.
Uri
pushOntoQuery(string $key, mixed $value)
Push a value onto the end of a query string parameter that is a list.
Uri
withoutQuery(array $keys)
Remove the given query parameters from the URI.
Uri
replaceQuery(array $query)
Specify new query parameters for the URI.
Uri
withFragment(string $fragment)
Specify the fragment of the URI.
RedirectResponse
redirect(int $status = 302, array $headers = [])
Create a redirect HTTP response for the given URI.
Response
toResponse(Request $request)
Create an HTTP response that represents the object.
string
toHtml()
Get content as a string of HTML.
string
decode()
Get the decoded string representation of the URI.
string
value()
Get the string representation of the URI.
bool
isEmpty()
Determine if the URI is currently an empty string.
static void
setUrlGeneratorResolver(Closure $urlGeneratorResolver)
Set the URL generator resolver.
UriInterface
getUri()
Get the underlying URI instance.
string
__toString()
Get the string representation of the URI.