Uri
class Uri implements Htmlable, Responsable, Stringable (View source)
Traits
Properties
static protected array | $macros | The registered string macros. |
from Macroable |
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.
Dump the string representation of the URI.
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
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.
Create a signed route URI instance for a named route.
Create a temporary signed route URI instance for a named route.
Get a URI instance for a controller action.
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 path segments.
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.
never
dd(mixed ...$args)
Dump the given arguments and terminate execution.
$this
dump(mixed ...$args)
Dump the string representation of the URI.
static void
macro(string $name, object|callable $macro)
Register a custom macro.
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
static bool
hasMacro(string $name)
Checks if macro is registered.
static void
flushMacros()
Flush the existing macros.
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
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.
static Uri
signedRoute(BackedEnum|string $name, mixed $parameters = [], DateTimeInterface|DateInterval|int|null $expiration = null, bool $absolute = true)
Create a signed route URI instance for a named route.
static Uri
temporarySignedRoute(BackedEnum|string $name, DateTimeInterface|DateInterval|int $expiration, array $parameters = [], bool $absolute = true)
Create a temporary signed route URI instance for a named route.
static Uri
action(string|array $action, mixed $parameters = [], bool $absolute = true)
Get a URI instance for a controller action.
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 "/".
Collection
pathSegments()
Get the URI's path segments.
Empty or missing paths are returned as an empty collection.
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|string $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.