Creating named routes

From the beginning, even in a small project, I highly suggest naming routes. I will cover a few examples of how and why here.

Getting ready

A base install of Laravel is great. I will use some routes and views from above but you can easily follow along.

How to do it…

Follow the listed steps for creating named routes:

  1. To begin with, let's look at some routes I have:
    > php artisan route:list
    

    You will see something like this if you followed along so far, else you will just see the default Laravel route.

    How to do it…
  2. Notice the name section; that is what we are aiming for here.
  3. Note the admin section admin.memberships and admin.users in my app/routes.php ...

Get Laravel 5.x Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.