[Solved] Laravel 10 - Call to undefined function str_slug()

June 16, 2023

[Solved] Laravel 10 - Call to undefined function str_slug()

There are two solutions.

1. Str::slug

Use the Str::slug method generates a URL friendly slug from the given string:


use Illuminate\Support\Str;
 
$slug = Str::slug('Laravel 5 Framework', '-');

2. Helpers functions

Use helpers functions then need to install new composer package:

composer require laravel/helpers

Use helper function as bellow:


$exampleSlug = str_slug('Laravel 5 Framework');