[英]Fatal Error Laravel: Uncaught ReflectionException when i view my Site
I have the following error when i view my site.查看我的网站时出现以下错误。
My Error:<\/strong>我的错误:<\/strong>
Fatal error: Uncaught ReflectionException: Class log does not exist in \/home\/vagrant\/Code\/in10km\/vendor\/laravel\/framework\/src\/Illuminate\/Container\/Container.php:741> Stack trace: #0 \/home\/vagrant\/Code\/in10km\/vendor\/laravel\/framework\/src\/Illuminate\/Container\/Container.php(741): ReflectionClass->__construct('log') #1 \/home\/vagrant\/Code\/in10km\/vendor\/laravel\/framework\/src\/Illuminate\/Container\/Container.php(631): Illuminate\\Container\\Container->build('log', Array) #2 \/home\/vagrant\/Code\/in10km\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Application.php(674): Illuminate\\Container\\Container->make('log', Array) #3 \/home\/vagrant\/Code\/in10km\/vendor\/laravel\/framework\/src\/Illuminate\/Container\/Container.php(842): Illuminate\\Foundation\\Application->make('log') #4 \/home\/vagrant\/Code\/in10km\/vendor\/laravel\/framework\/src\/Illuminate\/Container\/Container.php(805): Illuminate\\Container\\Container->resolveClass(Object(ReflectionParameter)) > #5 \/home\/vagrant\/Code\/in10km\/vendor\/laravel\/framework\/src\/Ill致命错误:未捕获的 ReflectionException:类日志在 \/home\/vagrant\/Code\/in10km\/vendor\/laravel\/framework\/src\/Illuminate\/Container\/Container.php:741 中不存在> 堆栈跟踪:#0 \/home\/vagrant\/Code \/in10km\/vendor\/laravel\/framework\/src\/Illuminate\/Container\/Container.php(741): ReflectionClass->__construct('log') #1 \/home\/vagrant\/Code\/in10km\/vendor\/laravel\/framework\/src\/ Illuminate\/Container\/Container.php(631): Illuminate\\Container\\Container->build('log', Array) #2 \/home\/vagrant\/Code\/in10km\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Application .php(674): Illuminate\\Container\\Container->make('log', Array) #3 \/home\/vagrant\/Code\/in10km\/vendor\/laravel\/framework\/src\/Illuminate\/Container\/Container.php(842) : Illuminate\\Foundation\\Application->make('log') #4 \/home\/vagrant\/Code\/in10km\/vendor\/laravel\/framework\/src\/Illuminate\/Container\/Container.php(805): Illuminate\\Container\\Container- >resolveClass(Object(ReflectionParameter)) > #5 \/home\/vagrant\/Code\/in10km\/vendor\/laravel\/framework\/src\/Ill uminate\/Container\/Container.php(774): Il in \/home\/vagrant\/Code\/in10km\/vendor\/laravel\/framework\/src\/Illuminate\/Container\/Container.php on line 741 uminate\/Container\/Container.php(774): Il in \/home\/vagrant\/Code\/in10km\/vendor\/laravel\/framework\/src\/Illuminate\/Container\/Container.php 在第 741 行
<\/blockquote>My Composer.json<\/strong> file is like this我的Composer.json<\/strong>文件是这样的
{ "name": "laravel\/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "type": "project", "require": { "php": ">=5.5.9", "laravel\/framework": "5.1.*", "doctrine\/dbal": "v2.4.2", "swiftmailer\/swiftmailer": "^5.4", "guzzlehttp\/guzzle": "~5.3|~6.0", "chrisbjr\/api-guard": "^2.3", "serverfireteam\/panel": "1.3.*", "laravel\/socialite": "^2.0" }, "require-dev": { "fzaninotto\/faker": "~1.4", "mockery\/mockery": "0.9.*", "phpunit\/phpunit": "~4.0", "phpspec\/phpspec": "~2.1" }, "autoload": { "files": [ "app\/Http\/helpers.php", "app\/Support\/helpers.php" ], "classmap": [ "database" ], "psr-4": { "App\\\\": "app\/" } }, "autoload-dev": { "classmap": [ "tests\/TestCase.php" ] }, "scripts": { "post-install-cmd": [ "php artisan clear-compiled", "php artisan optimize" ], "pre-update-cmd": [ "php artisan clear-compiled" ], "post-update-cmd": [ "php artisan optimize" ], "post-root-package-install": [ "php -r \\"copy('.env.example', '.env');\\"" ], "post-create-project-cmd": [ "php artisan key:generate" ] }, "config": { "preferred-install": "dist" } }<\/code><\/pre>
Anyone help me how to get rid of this error and view my site successfully.任何人都可以帮助我如何摆脱此错误并成功查看我的网站。
"
删除bootstrap/cache/
所有文件,然后运行:
composer dump-autoload -o
I found the solution, in my routes i don't called exactly the name of the Controller我找到了解决方案,在我的路线中,我没有准确地调用控制器的名称
Example:示例:
Route::get('/endpoint', 'Namebadcontroller@function');
// Correct name of route
Route::get('/endpoint', 'NameBadController@function');
And run the follow commands:并运行以下命令:
composer dump-autoload -o作曲家转储自动加载 -o
php artisan clear-compiled php artisan optimize php artisan 清晰编译 php artisan 优化
I had a similar issue.我有一个类似的问题。 I found that to really dig down into the issue, you need to modify the Illuminate/Container/Container.php file, as suggested here at the third from the top.我发现,要真正挖掘下到这个问题,你需要修改的照射/集装箱/ Container.php文件,如建议在这里从顶部第三。
<?php
namespace {
use Monolog\Logger as Monolog;
class log extends Illuminate\Log\Writer {
function __construct()
{
$this->monolog = new Monolog("local");
}
}
}
namespace Illuminate\Container {
use Closure;
use ArrayAccess;
use ReflectionClass;
use ReflectionMethod;
use ReflectionFunction;
use ReflectionParameter;
use InvalidArgumentException;
use Illuminate\Contracts\Container\Container as ContainerContract;
use Illuminate\Contracts\Container\BindingResolutionException as BindingResolutionContractException;
class Container implements ArrayAccess, ContainerContract
{
Modify it as the code suggests, and add an additional closing bracket to the bottom.按照代码建议修改它,并在底部添加一个额外的右括号。 This will allow it to display the error that it otherwise has been unable to display and thus be able to fix your problem!这将允许它显示否则无法显示的错误,从而能够解决您的问题!
删除供应商文件,然后运行composer update
The issue might originate from a package that is not (yet) downloaded in your vendor folder (with all installed vendor packages) In that case composer dump-autoload -o<\/code> does not fix your issue.
问题可能源于尚未(尚未)下载到您的供应商文件夹(包含所有已安装的供应商包)中的包在这种情况下,
composer dump-autoload -o<\/code>无法解决您的问题。
Check you
composer.json<\/code> and
composer.lock<\/code> .
检查你
composer.json<\/code>和
composer.lock<\/code> 。
I added main into my branch from a GIT repo.我从 GIT 存储库将 main 添加到我的分支中。
composer.json<\/code> and
composer.lock<\/code> did not match!
composer.json<\/code>和
composer.lock<\/code>不匹配!
The resolution was to recover
composer.json<\/code> and
composer.lock<\/code> from main and readded all changes from my branch manually.
解决方案是从 main 中恢复
composer.json<\/code>和
composer.lock<\/code>并手动从我的分支中读取所有更改。
Just to be sure I also removed my
vendor<\/code> folder.
只是为了确保我还删除了我的
vendor<\/code>文件夹。
Running
composer install<\/code> (re)installed all packages stored in composer.lock and added all (newer) not yet installed.
运行
composer install<\/code> (重新)安装了存储在 composer.lock 中的所有包,并添加了所有尚未安装的(较新的)包。
Notice that running
composer update<\/code> might fix the issue, but alse updates packages that perhaps may not be updated.
请注意,运行
composer update<\/code>可能会解决问题,但也会更新可能未更新的软件包。
"
Try the command composer dump-autoload -o
.尝试命令composer dump-autoload -o
。
I used it to overcome the problem: 'Uncaught ReflectionException'.我用它来克服这个问题:'Uncaught ReflectionException'。
Good luck!祝你好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.