Adding clean URLS for the users profile page

There is nothing like sending a user to profile/44444-55555-6666-7777 or any page in our application. In this recipe, I will add some slugs to the user profile page.


Slug? Semantic URL

Semantic URLs, also sometimes referred to as clean URLs, RESTful URLs, user-friendly URLs, or search engine-friendly URLs…

Refer to Wikipedia for more information: and see an example slug in that URL.

Getting ready

A fresh install of Laravel can work for you with a database for making users for whom you can add a Slug.

How to do it…

  1. Install the needed library from
    >composer require spatie/laravel-sluggable 
  2. Update the database ...

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.