phplaravelfunctionlaravel-6laravel-upgrade

Call to undefined function App\Providers\studly_case() after upgrade to Laravel 6.0.x


As I mentioned in the question, I just upgraded the Laravel version of my project from 5.8.* to 6.0.*.

Now I am getting the below error:

In AppServiceProvider.php line 32:
Call to undefined function App\Providers\studly_case()

Is Laravel supposed to throw error in it's own core file ? I was invoking the following command when I got this error, so I suppose this happens with any artisan command:

php artisan list

I saw in docs, that the new function is Str::studly from Str class file. Is it ok to change in the AppServiceProvider.php ?


Solution

  • Referring to the Laravel 6.x docs, I just discovered that the function for converting the string's current case to studly case is moved to Illuminate\Support\Str class, and named as studly().

    So I added that dependency and then replaced the studly_case() to Str::studly() in AppServiceProvider.php, and then was able to run the artisan commands just like before.

    I wasn't sure that changing AppServiceProvider.php is standard way or not, but it did worked so I am posting the answer here, that way it'll help anyone else facing the same issue.