How to create URL Slug in Laravel?
Generally we require to create slug when we are for front application in laravel, i mean like shopping website, social website because we should have good slug URL for post. So, Laravel provides several string helper like str_limit, str_plural, str_finish, str_singular etc and also str_slug().
generate url slug with laravel 6, laravel 7, laravel 8, laravel 9 and laravel 10 version.
str_slug() through we can make proper slug like remove space, remove special character etc. that way it also good for SEO friendly URL. you can see i give syntax and example of str_slug() helper.
Syntax:
Str::slug(string)
OR
str_slug(string);
Example 1:
$mySlug = Str::slug('It Solutions provide laravel examples');
print_r($mySlug);
Output:
it-solutions-provide-laravel-examples
Example 2:
$mySlug = str_slug('It Solutions provide laravel examples');
print_r($mySlug);
Output:
it-solutions-provide-laravel-examples
I hope it can help you...

Hardik Savani
I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- Laravel Eloquent Delete Record By ID Example
- Laravel Datatables Server Side Processing Example
- How to Generate PDF with Graph in Laravel?
- How to Create Custom Helper Function in Laravel 7?
- Laravel Broadcast Redis Socket io Tutorial
- PayPal Integration in Laravel 7/6 Example
- Stripe Payment Gateway Integration in Codeigniter Example
- How to Get Query Strings Value in Laravel?
- Mysql procedure with pagination in laravel?
- How to Set URL without Http of Other Site in Laravel?