Uri
class Uri implements Htmlable, JsonSerializable, Responsable, Stringable
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected UriInterface | $uri | The URI instance. |
|
| static protected Closure|null | $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.
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.
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 authority.
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 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.
Remove the fragment from the URI.
Create a redirect HTTP response for the given URI.
Get the URI as a Stringable instance.
Get the URI as a string of HTML.
Get the decoded string representation of the URI.
Get the string representation of the URI.
Get the string representation of the URI.
Determine if the URI is currently an empty string.
Determine if the URI is not an empty string.
Get the underlying URI instance.
Convert the object into a value that is JSON serializable.
Get the string representation of the URI.
Flush all static state.
Details
in
Conditionable at line 23
mixed
when(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) truthy.
in
Conditionable at line 56
mixed
unless(mixed $value = null, callable|null $callback = null, callable|null $default = null)
Apply the callback if the given "value" is (or resolves to) falsy.
in
Dumpable at line 12
never
dd(mixed ...$args)
Dump the given arguments and terminate execution.
at line 411
Uri
dump(mixed ...$args)
Dump the string representation of the URI.
in
Macroable at line 28
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 41
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 68
static void
flushMacros()
Flush the existing macros.
Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 103
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
in
Tappable at line 15
mixed
tap(callable|null $callback = null)
Call the given Closure with this instance then return the instance.
at line 46
__construct(string|Stringable|UriInterface $uri = '')
Create a new parsed URI instance.
at line 54
static Uri
of(string|Stringable|UriInterface $uri = '')
Create a new URI instance.
at line 62
static Uri
to(string $path)
Get a URI instance of an absolute URL for the given path.
at line 72
static Uri
route(BackedEnum|string $name, array $parameters = [], bool $absolute = true)
Get a URI instance for a named route.
at line 82
static Uri
signedRoute(BackedEnum|string $name, array $parameters = [], DateInterval|DateTimeInterface|int|null $expiration = null, bool $absolute = true)
Create a signed route URI instance for a named route.
at line 90
static Uri
temporarySignedRoute(BackedEnum|string $name, DateInterval|DateTimeInterface|int|null $expiration = null, array $parameters = [], bool $absolute = true)
Create a temporary signed route URI instance for a named route.
at line 100
static Uri
action(array|string $action, array $parameters = [], bool $absolute = true)
Get a URI instance for a controller action.
at line 108
string|null
authority()
Get the URI's authority.
at line 116
string|null
scheme()
Get the URI's scheme.
at line 124
string|null
user(bool $withPassword = false)
Get the user from the URI.
at line 134
string|null
password()
Get the password from the URI.
at line 142
string|null
host()
Get the URI's host.
at line 150
int|null
port()
Get the URI's port.
at line 162
string
path()
Get the URI's path.
Empty or missing paths are returned as a single "/".
at line 174
Collection
pathSegments()
Get the URI's path segments.
Empty or missing paths are returned as an empty collection.
at line 184
UriQueryString
query()
Get the URI's query string.
at line 192
string|null
fragment()
Get the URI's fragment.
at line 200
Uri
withScheme(string|Stringable $scheme)
Specify the scheme of the URI.
at line 208
Uri
withUser(string|Stringable|null $user, string|Stringable|null $password = null)
Specify the user and password for the URI.
at line 216
Uri
withHost(string|Stringable $host)
Specify the host of the URI.
at line 224
Uri
withPort(int|null $port)
Specify the port of the URI.
at line 232
Uri
withPath(string|Stringable $path)
Specify the path of the URI.
at line 240
Uri
withQuery(array $query, bool $merge = true)
Merge new query parameters into the URI.
at line 270
Uri
withQueryIfMissing(array $query)
Merge new query parameters into the URI if they are not already in the query string.
at line 286
Uri
pushOntoQuery(string $key, mixed $value)
Push a value onto the end of a query string parameter that is a list.
at line 303
Uri
withoutQuery(array|string $keys)
Remove the given query parameters from the URI.
at line 311
Uri
replaceQuery(array $query)
Specify new query parameters for the URI.
at line 319
Uri
withFragment(string $fragment)
Specify the fragment of the URI.
at line 327
Uri
withoutFragment()
Remove the fragment from the URI.
at line 335
RedirectResponse
redirect(int $status = 302, array $headers = [])
Create a redirect HTTP response for the given URI.
at line 343
Stringable
toStringable()
Get the URI as a Stringable instance.
at line 351
Response
toResponse(Request $request)
Create an HTTP response that represents the URI object.
at line 359
string
toHtml()
Get the URI as a string of HTML.
at line 367
string
decode()
Get the decoded string representation of the URI.
at line 379
string
value()
Get the string representation of the URI.
at line 387
string
toString()
Get the string representation of the URI.
at line 395
bool
isEmpty()
Determine if the URI is currently an empty string.
at line 403
bool
isNotEmpty()
Determine if the URI is not an empty string.
at line 424
static void
setUrlGeneratorResolver(Closure $urlGeneratorResolver)
Set the URL generator resolver.
Boot-only. The resolver persists in a static property for the worker lifetime and is used by every subsequent URI route/action helper.
at line 432
UriInterface
getUri()
Get the underlying URI instance.
at line 440
string
jsonSerialize()
Convert the object into a value that is JSON serializable.
at line 448
string
__toString()
Get the string representation of the URI.
at line 456
static void
flushState()
Flush all static state.