Illuminate Container.php中的RefelectionException。类注入不存在

时间:2017-02-26 10:17:49

标签: php laravel lumen

我只是将这个Lumen项目从我的本地机器导入到Ubuntu 14.04 VirtualBox。两个完全相同的代码。

我尝试过作曲家更新,作曲家安装。另外,从其他类型的simillar问题我已经将它添加到composer.json

"autoload": {
    "psr-4": {
        "App\\": "app/"
    },
    "files": [
            "app/Library/recaptchalib.php",
            "app/Library/function.php"
    ],
    "classmap": [
        "database/"
    ]
},
"autoload-dev": {
    "classmap": [
        "tests/TestCase.php" //added this
    ]
},

这是完整的错误日志

ReflectionException in Container.php line 741:
Class injection does not exist

in /var/www/lumen_app_test/vendor/illuminate/container/Container.php line 741
at ReflectionClass->__construct('injection') in Container.php line 741
at Container->build('injection', array()) in Container.php line 631
at Container->make('injection', array()) in Application.php line 447
at Application->make('injection') in Pipeline.php line 123
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Application.php line 1439
at Application->sendThroughPipeline(array('injection', 'App\Http\Middleware\LanguageMiddleware', 'App\Http\Middleware\AssetVersionMiddleware'), object(Closure)) in Application.php line 1284
at Application->handleFoundRoute(array(true, array('as' => 'home', 'uses' => 'App\Http\Controllers\HomeController@index', 'middleware' => array('injection', 'language', 'asset_version')), array())) in Application.php line 1207
at Application->Laravel\Lumen\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 139
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 49
at ShareErrorsFromSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(ShareErrorsFromSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 62
at StartSession->handle(object(Request), object(Closure))
at call_user_func_array(array(object(StartSession), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 37
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure))
at call_user_func_array(array(object(AddQueuedCookiesToResponse), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 59
at EncryptCookies->handle(object(Request), object(Closure))
at call_user_func_array(array(object(EncryptCookies), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 103
at Pipeline->then(object(Closure)) in Application.php line 1439
at Application->sendThroughPipeline(array('Illuminate\Cookie\Middleware\EncryptCookies', 'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse', 'Illuminate\Session\Middleware\StartSession', 'Illuminate\View\Middleware\ShareErrorsFromSession'), object(Closure)) in Application.php line 1213
at Application->dispatch(object(Request)) in Application.php line 1153
at Application->run(object(Request)) in index.php line 29

让我感到困惑的是,这个应用程序在我的其他计算机上运行没有任何问题。

1 个答案:

答案 0 :(得分:0)

您是否在任何地方应用了名为~/public_html的中间件?或者它是在injection的构造函数中?看起来容器正在寻找该中间件的定义但找不到它(它通常会在HomeController中。

如果所有其他方法都失败了,请删除app/Http/Kernel.php,然后运行/vendor以获取所有内容的新副本。