master

laravel/framework

Last updated at: 29/12/2023 09:25

URL.php

TLDR

The URL.php file is a part of the Illuminate\Support\Facades namespace and contains a class called URL. This class extends the Facade class and provides a variety of static methods for generating and manipulating URLs. The methods include generating full and current URLs, generating URLs for a given path, generating secure URLs, generating asset URLs, formatting URLs, working with signed routes, checking validity of signatures, and more.

Classes

URL

The URL class extends the Facade class and provides methods for generating and manipulating URLs. It serves as a facade for the underlying UrlGenerator class.

In the provided documentation block, you can find a list of available methods and their descriptions. Some notable methods are:

  • full(): Returns the URL for the current request including the query string.
  • current(): Returns the URL for the current request without the query string.
  • previous($fallback = false): Returns the URL of the previous request. If no previous request exists, it returns the given fallback value.
  • to($path, $extra = [], $secure = null): Generates a URL for the given path, appending any extra parameters and a specified secure flag.
  • asset($path, $secure = null): Generates a URL for an asset file located in the public directory of the application.
  • signedRoute($name, $parameters = [], $expiration = null, $absolute = true): Generates a URL for a signed route, which ensures the URL has not been tampered with.
  • route($name, $parameters = [], $absolute = true): Generates a URL for a named route.
  • isValidUrl($path): Checks if the given path is a valid URL.
  • defaults($defaults): Sets default parameters for generated URLs.

For a complete list of methods, refer to the provided documentation block.

<?php

namespace Illuminate\Support\Facades;

/**
 * @method static string full()
 * @method static string current()
 * @method static string previous(mixed $fallback = false)
 * @method static string previousPath(mixed $fallback = false)
 * @method static string to(string $path, mixed $extra = [], bool|null $secure = null)
 * @method static string secure(string $path, array $parameters = [])
 * @method static string asset(string $path, bool|null $secure = null)
 * @method static string secureAsset(string $path)
 * @method static string assetFrom(string $root, string $path, bool|null $secure = null)
 * @method static string formatScheme(bool|null $secure = null)
 * @method static string signedRoute(string $name, mixed $parameters = [], \DateTimeInterface|\DateInterval|int|null $expiration = null, bool $absolute = true)
 * @method static string temporarySignedRoute(string $name, \DateTimeInterface|\DateInterval|int $expiration, array $parameters = [], bool $absolute = true)
 * @method static bool hasValidSignature(\Illuminate\Http\Request $request, bool $absolute = true, array $ignoreQuery = [])
 * @method static bool hasValidRelativeSignature(\Illuminate\Http\Request $request, array $ignoreQuery = [])
 * @method static bool hasCorrectSignature(\Illuminate\Http\Request $request, bool $absolute = true, array $ignoreQuery = [])
 * @method static bool signatureHasNotExpired(\Illuminate\Http\Request $request)
 * @method static string route(string $name, mixed $parameters = [], bool $absolute = true)
 * @method static string toRoute(\Illuminate\Routing\Route $route, mixed $parameters, bool $absolute)
 * @method static string action(string|array $action, mixed $parameters = [], bool $absolute = true)
 * @method static array formatParameters(mixed|array $parameters)
 * @method static string formatRoot(string $scheme, string|null $root = null)
 * @method static string format(string $root, string $path, \Illuminate\Routing\Route|null $route = null)
 * @method static bool isValidUrl(string $path)
 * @method static void defaults(array $defaults)
 * @method static array getDefaultParameters()
 * @method static void forceScheme(string|null $scheme)
 * @method static void forceRootUrl(string|null $root)
 * @method static \Illuminate\Routing\UrlGenerator formatHostUsing(\Closure $callback)
 * @method static \Illuminate\Routing\UrlGenerator formatPathUsing(\Closure $callback)
 * @method static \Closure pathFormatter()
 * @method static \Illuminate\Http\Request getRequest()
 * @method static void setRequest(\Illuminate\Http\Request $request)
 * @method static \Illuminate\Routing\UrlGenerator setRoutes(\Illuminate\Routing\RouteCollectionInterface $routes)
 * @method static \Illuminate\Routing\UrlGenerator setSessionResolver(callable $sessionResolver)
 * @method static \Illuminate\Routing\UrlGenerator setKeyResolver(callable $keyResolver)
 * @method static \Illuminate\Routing\UrlGenerator withKeyResolver(callable $keyResolver)
 * @method static \Illuminate\Routing\UrlGenerator resolveMissingNamedRoutesUsing(callable $missingNamedRouteResolver)
 * @method static string getRootControllerNamespace()
 * @method static \Illuminate\Routing\UrlGenerator setRootControllerNamespace(string $rootNamespace)
 * @method static void macro(string $name, object|callable $macro)
 * @method static void mixin(object $mixin, bool $replace = true)
 * @method static bool hasMacro(string $name)
 * @method static void flushMacros()
 *
 * @see \Illuminate\Routing\UrlGenerator
 */
class URL extends Facade
{
    /**
     * Get the registered name of the component.
     *
     * @return string
     */
    protected static function getFacadeAccessor()
    {
        return 'url';
    }
}