31

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?

jerik
  • 5,714
  • 8
  • 41
  • 80

1 Answers1

77

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

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291