流明5.3:'类文件系统不存在'在/var/www/project/vendor/illuminate/container/Container.php:749

时间:2017-06-24 02:45:59

标签: php laravel lumen

我一直试图将我们的api从Laravel迁移到Lumen但是当我尝试运行一个简单的工匠命令时,我得到了这个错误:

[2017-06-24 02:36:24] lumen.ERROR: exception 'ReflectionException' with message 'Class filesystem does not exist' in /var/www/{project-folder}/vendor/illuminate/container/Container.php:749
Stack trace:
#0 /var/www/{project-folder}/vendor/illuminate/container/Container.php(749): ReflectionClass->__construct('filesystem')
#1 /var/www/{project-folder}/vendor/illuminate/container/Container.php(644): Illuminate\Container\Container->build('filesystem', Array)
#2 /var/www/{project-folder}/vendor/laravel/lumen-framework/src/Application.php(212): Illuminate\Container\Container->make('filesystem', Array)
#3 /var/www/{project-folder}/vendor/illuminate/container/Container.php(1203): Laravel\Lumen\Application->make('filesystem')
#4 /var/www/{project-folder}/vendor/illuminate/support/Facades/Facade.php(175): Illuminate\Container\Container->offsetGet('filesystem')
#5 /var/www/{project-folder}/vendor/illuminate/support/Facades/Facade.php(144): Illuminate\Support\Facades\Facade::resolveFacadeInstance('filesystem')
#6 /var/www/{project-folder}/vendor/illuminate/support/Facades/Facade.php(231): Illuminate\Support\Facades\Facade::getFacadeRoot()
#7 /var/www/{project-folder}/vendor/websight/l5-google-cloud-storage/src/Websight/GcsProvider/CloudStorageServiceProvider.php(46): Illuminate\Support\Facades\Facade::__callStatic('extend', Array)
#8 /var/www/{project-folder}/vendor/websight/l5-google-cloud-storage/src/Websight/GcsProvider/CloudStorageServiceProvider.php(46): Illuminate\Support\Facades\Storage::extend('gcs', Object(Closure))
#9 [internal function]: Websight\GcsProvider\CloudStorageServiceProvider->boot()
#10 /var/www/{project-folder}/vendor/illuminate/container/Container.php(508): call_user_func_array(Array, Array)
#11 /var/www/{project-folder}/vendor/laravel/lumen-framework/src/Application.php(178): Illuminate\Container\Container->call(Array)
#12 /var/www/{project-folder}/bootstrap/app.php(87): Laravel\Lumen\Application->register('Websight\\GcsPro...')
#13 /var/www/{project-folder}/artisan(18): require('/var/www/daysta...')
#14 {main}  

这就是我们app.php的样子

<?php

require_once __DIR__.'/../vendor/autoload.php';

try {
    (new Dotenv\Dotenv(__DIR__.'/../'))->load();
} catch (Dotenv\Exception\InvalidPathException $e) {
    //
}

/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| Here we will load the environment and create the application instance
| that serves as the central piece of this framework. We'll use this
| application as an "IoC" container and router for this framework.
|
*/

$app = new Laravel\Lumen\Application(
    realpath(__DIR__.'/../')
);

 $app->withFacades();
 $app->withEloquent();

/*
|--------------------------------------------------------------------------
| Register Container Bindings
|--------------------------------------------------------------------------
|
| Now we will register a few bindings in the service container. We will
| register the exception handler and the console kernel. You may add
| your own bindings here if you like or you can make another file.
|
*/

$app->singleton(
    Illuminate\Contracts\Debug\ExceptionHandler::class,
    App\Exceptions\Handler::class
);

$app->singleton(
    Illuminate\Contracts\Console\Kernel::class,
    App\Console\Kernel::class
);

/*
|--------------------------------------------------------------------------
| Register Middleware
|--------------------------------------------------------------------------
|
| Next, we will register the middleware with the application. These can
| be global middleware that run before and after each request into a
| route or middleware that'll be assigned to some specific routes.
|
*/

// $app->middleware([
//    App\Http\Middleware\ExampleMiddleware::class
// ]);

// $app->routeMiddleware([
//     'auth' => App\Http\Middleware\Authenticate::class,
// ]);

/*
|--------------------------------------------------------------------------
| Register Service Providers
|--------------------------------------------------------------------------
|
| Here we will register all of the application's service providers which
| are used to bind services into the container. Service providers are
| totally optional, so you are not required to uncomment this line.
|
*/

 $app->register(App\Providers\AppServiceProvider::class);
 $app->register(App\Providers\AuthServiceProvider::class);
 $app->register(App\Providers\EventServiceProvider::class);
 $app->register(Tymon\JWTAuth\Providers\JWTAuthServiceProvider::class);
 $app->register(Barryvdh\Cors\ServiceProvider::class);
 $app->register(Illuminate\Redis\RedisServiceProvider::class);
 $app->register(Bogardo\Mailgun\MailgunServiceProvider::class);
 $app->register(Websight\GcsProvider\CloudStorageServiceProvider::class);
 $app->register(GrahamCampbell\Flysystem\FlysystemServiceProvider::class);
 $app->register(Illuminate\Filesystem\FilesystemServiceProvider::class);
 $app->register(Illuminate\Cache\CacheServiceProvider::class);

 /*
  * configuration files
  */
 $app->configure('jwt');
 $app->configure('cors');
 $app->configure('database');
 $app->configure('cache');
 $app->configure('queue');
 $app->configure('mailgun');
 $app->configure('mail');
 $app->configure('filesystem');

/*
|--------------------------------------------------------------------------
| Load The Application Routes
|--------------------------------------------------------------------------
|
| Next we will include the routes file so that they can all be added to
| the application. This will provide all of the URLs the application
| can respond to, as well as the controllers that may handle them.
|
*/

$app->group(['namespace' => 'App\Http\Controllers'], function ($app) {
    require __DIR__.'/../routes/web.php';
});

return $app;

我知道不是Laravel的所有功能都存在于Lumen中,但我在这里缺少什么?

<?php

namespace Websight\GcsProvider;

use ErrorException;
use Google_Auth_AssertionCredentials;
use Google_Client;
use Google_Service_Storage;
use Illuminate\Support\ServiceProvider;
use League\Flysystem\Filesystem;
use Illuminate\Support\Facades\Storage;
use Superbalist\Flysystem\GoogleStorage\GoogleStorageAdapter;

    /**
     * Class CloudStorageServiceProvider
     * Configures Google Cloud Storage Access for flysystem
     *
     * @package Websight\GcsProvider
     */
    class CloudStorageServiceProvider extends ServiceProvider
    {
        /**
         * Bootstrap the application services.
         *
         * @return void
         */
        public function boot()
        {
            Storage::extend('gcs', function ($app, $config) {
                $credentials = new Google_Auth_AssertionCredentials(
                    $config['service_account'],
                    [
                        Google_Service_Storage::DEVSTORAGE_FULL_CONTROL
                    ],
                    file_get_contents($config['service_account_certificate']),
                    $config['service_account_certificate_password']
                );

                $client = new Google_Client();
                $client->setAssertionCredentials($credentials);

                $service = new Google_Service_Storage($client);
                $adapter = new GoogleStorageAdapter($service, $config['bucket']);

                return new Filesystem($adapter);
            });
        }

        /**
         * Register the application services.
         *
         * @return void
         */
        public function register()
        {
            // Not needed
        }
    }

1 个答案:

答案 0 :(得分:8)

PIL

中的容器绑定下添加以下右侧
bootstrap/app.php