...

/

Creating a URL Friendly Slug From a Title

Creating a URL Friendly Slug From a Title

Learn how to create a URL from a title using Laravel string functions.

We'll cover the following...

Creating a URL from a title

We can use the slug helper method to format the provided value into a URL-friendly version. This helper method is valuable when constructing URLs from dynamic input, such as a blog title.

Press + to interact
<?php
/**
* Versions: Laravel 8, 9
*
* @return string
*/
public static function slug(
string $title,
string $separator = '-',
string|null $language = 'en'
);

Internally, the slug helper ...