Error - Class 'App\Http\Controllers\Str' not found Code - Laravel

Mar 26, 2022 . Admin

Hi all,

This tutorial will give you simple example of error - class 'app\http\controllers\str' not found code - laravel. In this blog, we have share post of laravel str class not found. we will give you example of error class "App\Http\Controllers\Str" not found. this example will help you how error class "App\Http\Controllers\Str" not found solve example.

This comprehensive guide solve error Class 'App\Http\Controllers\Str' not found in laravel application.

So let's start following example solve error:

Error
Solution:

You must need to add "use Illuminate\Support\Str;" on top of controller, middleware, command, event or blade files. Let's see bellow:

use Illuminate\Support\Str;
Example:

You can see controller file code, how to use it.

<?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use Illuminate\Support\Str;
  
class UserController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $slug = Str::slug('This is a ItSolutionstuff.com website.');
  
        return view('users');
    }
}

I think you must have liked this example.....

#Laravel