Call to undefined function str_slug() in Laravel

10-Apr-2023

.

Admin

In this example i will show you solve laravel Call to undefined function str_slug(). you will find solution of Call to undefined function str_slug() in laravel 6 application.

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 1:


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

dd($exampleSlug);

Example 2:

but you want to use helpers functions then you need to install new composer package with command as bellow:

composer require laravel/helpers

Now you can use helper function as bellow:

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

dd($exampleSlug);

it will help you....

#Laravel

#Laravel 6