Method Illuminate\Support\Str::replace does not exist

Viewed 2319

I am using:

  • Laravel Version: 8.35.1
  • PHP Version: 7.4.9

On Tinker and Routing I use Str::replace() method as in the docs but get error:

BadMethodCallException with message Method Illuminate\Support\Str::replace does not exist.

Example 1:

root@c6dd4af63e3c:/var/www/html# php artisan tinker
Psy Shell v0.10.7 (PHP 7.4.9 — cli) by Justin Hileman
>>> Illuminate\Support\Str::replace('8.x', '9.x', 'Laravel 8.x');
BadMethodCallException with message 'Method Illuminate\Support\Str::replace does not exist.'
>>> 

Example2:

Route::get('/test', function () {
    return Illuminate\Support\Str::replace('8.x', '9.x', 'Laravel 8.x');
});

Why do I have this error and how to fix it?

1 Answers
Related