How to generate slug using str_slug() helper function in Laravel 5?
In this post we will give you information about How to generate slug using str_slug() helper function in Laravel 5?. Hear we will give you detail about How to generate slug using str_slug() helper function in Laravel 5?And how to use it also give you demo for it if it is necessary.
Its very important to have user friendly URL for SEO purpose and this help to user to know that website they are on is correct or not.
If there are spaces in URL then space will be replaced by %20 that is not good for user friendly so you always need sluggify URL.
Working with Laravel, this is much more easier to generate slug from given string using str_slug
method.
There are so many helper method provides by Laravel that can be used in your application.
When you work with laravel framework then always use all defined functionality that will save your time and effort.
str_slug
generate sluggify url from given string if there are spaces or special character in string that is not good for user friendly URL then it remove all these spaces and special character from string.
Example:
$slug = str_slug('onlinecode provides PHP Tutorials Best For Beginners'); print_r($slug);
Output :
onlinecodein-provides-php-tutorials-best-for-beginners
As you know there are so many global helper PHP functions in Laravel so you are free to use them into your application.
Hope this code and post will helped you for implement How to generate slug using str_slug() helper function in Laravel 5?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs