Laravel 6 Call to undefined function str_slug() - Solved
Few days ago my blog viewer send me one error Call to undefined function str_slug() in laravel 6 and he told me to all string and array function like str_limit, str_uuid, array_sort, array_only, array_except etc and call as laravel 6 Call to undefined function.
So basically, you can not use string and array helpers in laravel 6. laravel 6 removed helpers function from repo. You can use Illuminate\Support\Str and Illuminate\Support\Arr classes for helpers. so you can use all helpers function like as bellow:
Now you can use like as bellow example:
Solution 1:
Route::get('/', function () {
$newSlug = Str::slug('I am from ItSolutionStuff.com');
dd($newSlug);
});
Solution 2:
but you want to use helpers functions then you need to install new composer package with following command:
composer require laravel/helpers
Now you can use helper function like as bellow:
Route::get('/', function () {
$newSlug = str_slug('I am from ItSolutionStuff.com');
dd($newSlug);
});
You can use Helpers like this way:
Arr::add
Arr::collapse
Arr::divide
Arr::dot
Arr::except
Arr::first
Arr::flatten
Arr::forget
Arr::get
Arr::has
Arr::last
Arr::only
Arr::pluck
Arr::prepend
Arr::pull
Arr::random
Arr::set
Arr::sort
Arr::sortRecursive
Arr::where
Arr::wrap
Str::after
Str::before
Str::camel
Str::contains
Str::containsAll
Str::endsWith
Str::finish
Str::is
Str::kebab
Str::limit
Str::orderedUuid
Str::plural
Str::random
Str::replaceArray
Str::replaceFirst
Str::replaceLast
Str::singular
Str::slug
Str::snake
Str::start
Str::startsWith
Str::studly
Str::title
Str::uuid
Str::words
I hope it can help you...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. 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 6 Multiple Image Upload Tutorial
- Laravel 7/6 Ajax CRUD Tutorial
- Laravel 6 Generate PDF File Tutorial
- Laravel 6 Authentication Tutorial
- Laravel 6 Form Validation with Error Messages
- Laravel 6 Ajax Autocomplete Search from Database
- Laravel 6 Image Upload Tutorial
- Laravel 6 CRUD Application Tutorial