Laravel 6 Call to undefined function str_slug() - Solved

By Hardik Savani | September 18, 2019 | | 6705 Viewer | Category : Laravel


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
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. 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, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
Follow Me: Github Twitter
***Do you want me hire for your Project Work? Then Contact US.


We are Recommending you: