【问题标题】:production.ERROR: exception 'ReflectionException' with message 'Class cors does not exist'production.ERROR:异常“ReflectionException”,消息“类 cors 不存在”
【发布时间】:2015-12-15 09:48:25
【问题描述】:

在本地我没有收到错误,但是当我部署到我的服务器(使用 Git)时,我收到以下错误:

production.ERROR: exception 'ReflectionException' with message 'Class cors does not exist' in /home/ruben/apps/bootstrap/cache/compiled.php:1244
Stack trace:
#0 /home/ruben/apps/bootstrap/cache/compiled.php(1244): ReflectionClass->__construct('cors')
#1 /home/ruben/apps/bootstrap/cache/compiled.php(1195): Illuminate\Container\Container->build('cors', Array)
#2 /home/ruben/apps/bootstrap/cache/compiled.php(1733): Illuminate\Container\Container->make('cors', Array)
#3 /home/ruben/apps/bootstrap/cache/compiled.php(9459): Illuminate\Foundation\Application->make('cors')
#4 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#5 /home/ruben/apps/bootstrap/cache/compiled.php(9449): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#6 /home/ruben/apps/bootstrap/cache/compiled.php(7375): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#7 /home/ruben/apps/bootstrap/cache/compiled.php(7363): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))
#8 /home/ruben/apps/bootstrap/cache/compiled.php(7348): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#9 /home/ruben/apps/bootstrap/cache/compiled.php(2262): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#10 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}(Object(Illuminate\Http\Request))
#11 /home/ruben/apps/bootstrap/cache/compiled.php(9467): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#12 /home/ruben/apps/bootstrap/cache/compiled.php(2882): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#13 [internal function]: Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))
#14 /home/ruben/apps/bootstrap/cache/compiled.php(9459): call_user_func_array(Array, Array)
#15 /home/ruben/apps/bootstrap/cache/compiled.php(12755): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#16 [internal function]: Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#17 /home/ruben/apps/bootstrap/cache/compiled.php(9459): call_user_func_array(Array, Array)
#18 /home/ruben/apps/bootstrap/cache/compiled.php(11390): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#19 [internal function]: Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))
#20 /home/ruben/apps/bootstrap/cache/compiled.php(9459): call_user_func_array(Array, Array)
#21 /home/ruben/apps/bootstrap/cache/compiled.php(12496): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#22 [internal function]: Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))
#23 /home/ruben/apps/bootstrap/cache/compiled.php(9459): call_user_func_array(Array, Array)
#24 /home/ruben/apps/bootstrap/cache/compiled.php(12435): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#25 [internal function]: Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))
#26 /home/ruben/apps/bootstrap/cache/compiled.php(9459): call_user_func_array(Array, Array)
#27 /home/ruben/apps/bootstrap/cache/compiled.php(2932): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#28 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))
#29 /home/ruben/apps/bootstrap/cache/compiled.php(9459): call_user_func_array(Array, Array)
#30 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))
#31 /home/ruben/apps/bootstrap/cache/compiled.php(9449): call_user_func(Object(Closure), Object(Illuminate\Http\Request))
#32 /home/ruben/apps/bootstrap/cache/compiled.php(2209): Illuminate\Pipeline\Pipeline->then(Object(Closure))
#33 /home/ruben/apps/bootstrap/cache/compiled.php(2192): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#34 /home/ruben/apps/public/index.php(54): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#35 {main}

我已经删除了我的 /vendor 文件夹和 composer.lock 文件并再次运行 composer install。我查了一下,类的文件都在那里...

我希望有人可以帮助我。

更新 我得到了一些关于区分大小写的提示。我真的不知道如何使用这个技巧,因为我只是使用 composer.json 来安装包。我决定注释掉 cors 的东西,然后弹出下一个错误:

production.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'JWTAuth' not found' in 

这是一个类似的错误,我在与 Cors 类同时添加的类。我不知道为什么没有加载这些类。

【问题讨论】:

  • 你的本地机器是windows和生产linux吗?检查是否区分大小写,因为它正在寻找带有小写 ccors
  • 是的。具体来说,您要检查类文件的文件名在大小写方面是否与类名完全匹配。自动加载器不会在名为“Cors.php”的文件中找到名为“cors”的类。
  • 这似乎是正确的。尽管我真的不知道如何正确调试它。我刚刚通过 composer 安装了这个包:github.com/barryvdh/laravel-cors

标签: laravel laravel-5 composer-php autoload autoloader


【解决方案1】:

对不起,我来晚了,我刚刚解决了。到你的项目根目录并运行:

composer dump-autoload

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-09-04
    • 1970-01-01
    • 2016-07-04
    • 2014-12-11
    • 2017-11-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多