Laravel URL Generation: URLs For Named Routes

Allow you to generate URLs without being coupled to the actual URL defined on the route.

Echo route('post.show', ['post' => 1]);

// http://example.com/post/1
Echo route('post.show', ['post' => $post]);

Signed URLs

Use Illuminate\Support\Facades\URL;

return URL::signedRoute('unsubscribe', ['user' => 1]);
Use Illuminate\Support\Facades\URL;

return URL::temporarySignedRoute(
    'unsubscribe', now()->addMinutes(30), ['user' => 1]
);
  • Laravel allows you to easily create "signed" URLs to named routes.
  • Have a "signature" hash appended to the query string which allows Laravel to verify that the URL has not been modified since it was created.
  • Are especially useful for routes that are publicly accessible yet need a layer of protection against URL manipulation.

Laravel URL Generation: URLs For Named Routes — Structure map

Clickable & Draggable!

Laravel URL Generation: URLs For Named Routes — Related pages: