Error class 'app\http\controllers\storage' - Laravel

Mar 25, 2022 . Admin



Today I explain laravel - class 'app\http\controllers\storage' not found. In this laravel download file from public storage folder example, you will learn how to download or display files from public storage folder in laravel apps. In this tutorial, you will learn laravel storage class not found.

You can solve 'Class "App\Http\Controllers\Storage" not found' issue in laravel 6, laravel 7, laravel 8 and laravel 9 version.

So let's start following Issue:

Solution:

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

use Illuminate\Support\Facades\Storage;
Example:

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

<?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
  
class UserController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        Storage::put('example.txt', 'Contents');
  
        return view('users');
    }
}

I hope it can help you...

#Laravel