class Illuminate / Routing / UrlGenerator

UrlGenerator

Implements

Uses

Properties

protected

$routes RouteCollectionInterface

The route collection.

Default: null
protected

$request Request

The request instance.

Default: null
protected

$assetRoot string

The asset root URL.

Default: null
protected

$forcedRoot string

The forced URL root.

Default: null
protected

$forceScheme string

The forced scheme for URLs.

Default: null
protected

$cachedRoot string|null

A cached copy of the URL root for the current request.

Default: null
protected

$cachedScheme string|null

A cached copy of the URL scheme for the current request.

Default: null
protected

$rootNamespace string

The root namespace being applied to controller actions.

Default: null
protected

$sessionResolver callable

The session resolver callable.

Default: null
protected

$keyResolver callable

The encryption key resolver callable.

Default: null
protected

$missingNamedRouteResolver callable

The missing named route resolver callable.

Default: null
protected

$formatHostUsing Closure

The callback to use to format hosts.

Default: null
protected

$formatPathUsing Closure

The callback to use to format paths.

Default: null
protected

$routeGenerator RouteUrlGenerator |null

The route URL generator instance.

Default: null

Methods

public

__construct ( RouteCollectionInterface $routes , Request $request , $assetRoot ) : void

Create a new URL Generator instance.

Parameters

public

full ( ) : string

Get the full URL for the current request.

public

current ( ) : string

Get the current URL for the request.

public

previous ( $fallback ) : string

Get the URL for the previous request.

Parameters

  • $fallback mixed
public

previousPath ( $fallback ) : string

Get the previous path info for the request.

Parameters

  • $fallback mixed
protected

getPreviousUrlFromSession ( ) : string|null

Get the previous URL from the session if possible.

public

to ( $path , $extra , $secure ) : string

Generate an absolute URL to the given path.

Parameters

  • $path string
  • $extra mixed
  • $secure bool|null
public

secure ( $path , $parameters ) : string

Generate a secure, absolute URL to the given path.

Parameters

  • $path string
  • $parameters array
public

asset ( $path , $secure ) : string

Generate the URL to an application asset.

Parameters

  • $path string
  • $secure bool|null
public

secureAsset ( $path ) : string

Generate the URL to a secure asset.

Parameters

  • $path string
public

assetFrom ( $root , $path , $secure ) : string

Generate the URL to an asset from a custom root domain such as CDN, etc.

Parameters

  • $root string
  • $path string
  • $secure bool|null
protected

removeIndex ( $root ) : string

Remove the index.php file from a path.

Parameters

  • $root string
public

formatScheme ( $secure ) : string

Get the default scheme for a raw URL.

Parameters

  • $secure bool|null
public

signedRoute ( $name , $parameters , $expiration , $absolute ) : string

Create a signed route URL for a named route.

Parameters

protected

ensureSignedRouteParametersAreNotReserved ( $parameters ) : void

Ensure the given signed route parameters are not reserved.

Parameters

  • $parameters mixed
public

temporarySignedRoute ( $name , $expiration , $parameters , $absolute ) : string

Create a temporary signed route URL for a named route.

Parameters

public

hasValidSignature ( Request $request , $absolute , array $ignoreQuery ) : bool

Determine if the given request has a valid signature.

Parameters

  • $request Request
  • $absolute bool
  • $ignoreQuery array
public

hasValidRelativeSignature ( Request $request , array $ignoreQuery ) : bool

Determine if the given request has a valid signature for a relative URL.

Parameters

public

hasCorrectSignature ( Request $request , $absolute , array $ignoreQuery ) : bool

Determine if the signature from the given request matches the URL.

Parameters

  • $request Request
  • $absolute bool
  • $ignoreQuery array
public

signatureHasNotExpired ( Request $request ) : bool

Determine if the expires timestamp from the given request is not from the past.

Parameters

public

route ( $name , $parameters , $absolute ) : string

Get the URL to a named route.

Parameters

  • $name string
  • $parameters mixed
  • $absolute bool
public

toRoute ( $route , $parameters , $absolute ) : string

Get the URL for a given route instance.

Parameters

  • $route Route
  • $parameters mixed
  • $absolute bool
public

action ( $action , $parameters , $absolute ) : string

Get the URL to a controller action.

Parameters

  • $action string|array
  • $parameters mixed
  • $absolute bool
protected

formatAction ( $action ) : string

Format the given controller action.

Parameters

  • $action string|array
public

formatParameters ( $parameters ) : array

Format the array of URL parameters.

Parameters

  • $parameters mixed|array
protected

extractQueryString ( $path ) : array

Extract the query string from the given path.

Parameters

  • $path string
public

formatRoot ( $scheme , $root ) : string

Get the base URL for the request.

Parameters

  • $scheme string
  • $root string|null
public

format ( $root , $path , $route ) : string

Format the given URL segments into a single URL.

Parameters

  • $root string
  • $path string
  • $route Route |null
public

isValidUrl ( $path ) : bool

Determine if the given path is a valid URL.

Parameters

  • $path string
protected

routeUrl ( ) : RouteUrlGenerator

Get the Route URL generator instance.

public

defaults ( array $defaults ) : void

Set the default named parameters used by the URL generator.

Parameters

  • $defaults array
public

getDefaultParameters ( ) : array

Get the default named parameters used by the URL generator.

public

forceScheme ( $scheme ) : void

Force the scheme for URLs.

Parameters

  • $scheme string|null
public

forceRootUrl ( $root ) : void

Set the forced root URL.

Parameters

  • $root string|null
public

formatHostUsing ( Closure $callback ) : $this

Set a callback to be used to format the host of generated URLs.

Parameters

public

formatPathUsing ( Closure $callback ) : $this

Set a callback to be used to format the path of generated URLs.

Parameters

public

pathFormatter ( ) : Closure

Get the path formatter being used by the URL generator.

public

getRequest ( ) : Request

Get the request instance.

public

setRequest ( Request $request ) : void

Set the current request instance.

Parameters

public

setRoutes ( RouteCollectionInterface $routes ) : $this

Set the route collection.

Parameters

protected

getSession ( ) : Store |null

Get the session implementation from the resolver.

public

setSessionResolver ( callable $sessionResolver ) : $this

Set the session resolver for the generator.

Parameters

  • $sessionResolver callable
public

setKeyResolver ( callable $keyResolver ) : $this

Set the encryption key resolver.

Parameters

  • $keyResolver callable
public

withKeyResolver ( callable $keyResolver ) : UrlGenerator

Clone a new instance of the URL generator with a different encryption key resolver.

Parameters

  • $keyResolver callable
public

resolveMissingNamedRoutesUsing ( callable $missingNamedRouteResolver ) : $this

Set the callback that should be used to attempt to resolve missing named routes.

Parameters

  • $missingNamedRouteResolver callable
public

getRootControllerNamespace ( ) : string

Get the root controller namespace.

public

setRootControllerNamespace ( $rootNamespace ) : $this

Set the root controller namespace.

Parameters

  • $rootNamespace string