简体   繁体   English

"致命错误 Laravel:当我查看我的网站时未捕获 ReflectionException"

[英]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.

相关问题 致命错误:未捕获的异常&#39;ReflectionException&#39; - Fatal error: Uncaught exception 'ReflectionException' 致命错误:未捕获的 ReflectionException:方法 get_site_editor_type 不存在于...第 45 行 - Fatal error: Uncaught ReflectionException: Method get_site_editor_type does not exist in... on line 45 PHP致命错误,我网站中未捕获的错误 - PHP Fatal Error, Uncaught Error in my Site Laravel 5.1.11致命错误:消息为“类日志不存在”的未捕获异常“ Re​​flectionException” - Laravel 5.1.11 Fatal error: Uncaught exception 'ReflectionException' with message 'Class log does not exist' Laravel:致命错误:未捕获反射异常:Class App\Http\Kernel 不存在 - Laravel : Fatal error: Uncaught ReflectionException: Class App\Http\Kernel does not exist 在Laravel中设置自己的库时遇到ReflectionException错误 - ReflectionException error when setting up my own library in Laravel 致命错误:未捕获的 ReflectionException:Class “env”不存在 - Fatal error: Uncaught ReflectionException: Class "env" does not exist Laravel 未捕获异常 &#39;ReflectionException - Laravel Uncaught exception 'ReflectionException 致命错误:未捕获的 ReflectionException:Class 配置不存在 - Fatal error: Uncaught ReflectionException: Class config does not exist Laravel-未捕获的ReflectionException:类日志不存在-配置错误 - Laravel - Uncaught ReflectionException: Class log does not exist - Config error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM