我收到以下错误:
Class 'App\Http\Controllers\File' not found
当在laravel 5控制器中使用时:
$files = File::files( $this->csvDir );
我必须将Filesystem添加到 composer.json
和 config/app.php
. 不知怎的,我使用了错误的配置 .
这就是我改变的:
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
当我运行 composer update
时,它运行良好,但没有输出文件系统的输出 . 所以我的配置错了,但我不知道正确的方法 .
有什么建议或提示吗?
1 回答
首先,您应该考虑使用内置存储外观 . 您不需要手动包含
Filesystem
,除非您使用S3或Rackspace,因为默认情况下已经包含它 - 请查看Filesystem in Laravel 5 documentation .看来,你应该导入
File
,试试吧或
\File
来解决问题,因为现在您正在使用当前命名空间中的文件,并且App\Http\Controllers
命名空间中未定义File