Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 Class 'App\Http\Controllers\File' not found

i get the following error:

Class 'App\Http\Controllers\File' not found

when using in laravel 5 Controller:

$files = File::files( $this->csvDir );

I have to add the Filesystem to composer.json and config/app.php. Somehow I use a misconfiguration.

That's what I changed:

composer.json

    "require": {
        "laravel/framework": "5.0.*", 
        "illuminate/html": "5.*",
        "illuminate/filesystem": "5.*"  /* my try to repo */
    },

config/app.php

    'providers' => [

    // [...] 
    // jerik 2015-04-17: get html Forms
    // http://laravel.io/forum/09-20-2014-html-form-class-not-found-in-laravel-5
    'Illuminate\Html\HtmlServiceProvider', 
    'Illuminate\Filesystem\FilesystemServiceProvider', // try to add file

When I run composer update, it runs well, but there is no ouput that the Filesystem is downloaded. So my configuration is wrong, but I do not know the correct way.

Any suggestions or tips?

like image 314
jerik Avatar asked Apr 17 '15 16:04

jerik


1 Answers

First you shoud consider using built-in Storage facade. You don't need to include manually Filesystem unless you use S3 or Rackspace because it's already included by default - look at Filesystem in Laravel 5 documentation.

It also seems, that you should import File so try

use File;

or \File to solve the issue because now you are using File from current namespace and probably File is not defined in App\Http\Controllers namespace

like image 194
Marcin Nabiałek Avatar answered Nov 05 '22 22:11

Marcin Nabiałek