Atom Framework
Go to Github
v1.0.0
v1.0.0
  • Installation
  • Getting Started
  • Configuration
    • Environment
    • Authentication
  • Basics
    • Routing
    • Middleware
    • Controllers
    • Models
    • Requests
    • Views
    • URL Generation
    • Session
  • Misc
    • Security
      • Encryption
      • Hashing
    • Storage
    • Moment
Propulsé par GitBook

© 2025 Licon Corp

Sur cette page
  • Generate Basics URLs
  • URLs For Named Routes

Cet article vous a-t-il été utile ?

  1. Basics

URL Generation

Atom provides several helpers to assist you in generating URLs for your application. Of course, these are mainly helpful when building links in your templates and API responses, or when generating redirect responses to another part of your application.

Generate Basics URLs

The url helper may be used to generate arbitrary URLs for your application. The generated URL will automatically use the scheme (HTTP or HTTPS) and host from the current request:

$post = App\Models\Post::find(1);

echo url("/posts/{$post->id}");

// http://example.com/posts/1

URLs For Named Routes

The route helper may be used to generate URLs to named routes. Named routes allow you to generate URLs without being coupled to the actual URL defined on the route. Therefore, if the route's URL changes, no changes need to be made to your route function calls. For example, imagine your application contains a route defined like the following:

router()->get('/post/:post', function () {
    //
})->name('post.show');

To generate a URL to this route, you may use the route helper like so:

echo route('post.show', ['post' => 1]);
PrécédentViewsSuivantSession

Dernière mise à jour il y a 6 ans

Cet article vous a-t-il été utile ?