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

10-Apr-2023

.

Admin

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

Hi all,

In this blog, we have share post of laravel str class not found. This tutorial will give you simple example of Class "App\Http\Controllers\Str" not found - laravel. 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