Call to undefined function str_slug() in Laravel

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Now in this article, i will teach you how to solve Call to undefined function str_slug() in any laravel application. So now you will find a best solution of Call to undefined function str_slug() in laravel 8 application.

str_slug() generate sluggify url from any given string. If there are any spaces or any special character in string that is not good for user friendly URL then it removed all these spaces and special character from the string.

Example 1:

$exampleSlug = Str::slug('Example of str slug');

dd($exampleSlug);

But we want to use it on helpers functions then we need to install new composer package by using command as bellow:

composer require laravel/helpers

Now you can use helper function as like bellow:

$exampleSlug = str_slug('Example of str Slug');

dd($exampleSlug);

Read Also : Laravel 8 User Roles and Permissions Tutorial

Thanks for read. I hope it help you. For more you can follow us on facebook

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →