Laravel 5 Class 'App\Http\Controllers\File' not found
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
jerik
Updated on July 22, 2020Comments
-
jerik almost 4 years
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
andconfig/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?
-
Andrew Koper about 6 yearsI wish Laravel/artisan automatically added "use App[Model];" to the top of the controller when it created it.
-
saber tabatabaee yazdi over 4 yearsUndefined symbol 'File'.intelephense(1002)
-
monkeyhybrid over 4 years@sabertabatabaeeyazdi, did you work out how to get rid of that error message in VSCode? I get the same, even though the code runs fine.
-
monkeyhybrid over 4 years@sabertabatabaeeyazdi Looks like new behaviour / bug introduced in recent version of Intellephense. See stackoverflow.com/q/59149877/1467680