L5.1类App \ Console \ Kernel不存在 [英] L5.1 Class App\Console\Kernel does not exist

查看:66
本文介绍了L5.1类App \ Console \ Kernel不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我尝试运行composer updaterequirephp artisan时-我收到错误消息

whenever im trying to run composer update or require, or php artisan - i get error

root@websites:/var/www/rafdev.ovh/html/msvixen# composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating autoload files
> php artisan clear-compiled
PHP Fatal error:  Uncaught exception 'ReflectionException' with message 'Class App\Console\Kernel does not exist' in /var/www/rafdev.ovh/html/msvixen/vendor/laravel/framework/src/Illuminate/Container/Container.php:737
Stack trace:
#0 /var/www/rafdev.ovh/html/msvixen/vendor/laravel/framework/src/Illuminate/Container/Container.php(737): ReflectionClass->__construct('App\Console\Ker...')
#1 /var/www/rafdev.ovh/html/msvixen/vendor/laravel/framework/src/Illuminate/Container/Container.php(627): Illuminate\Container\Container->build('App\Console\Ker...', Array)
#2 /var/www/rafdev.ovh/html/msvixen/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(674): Illuminate\Container\Container->make('App\Console\Ker...', Array)
#3 /var/www/rafdev.ovh/html/msvixen/vendor/laravel/framework/src/Illuminate/Container/Container.php(216): Illuminate\Foundation\Application->make('App\Console\Ker...', Array)
#4 /var/www/rafdev.ovh/html/msvixen/vendor/laravel/framework/src/Illuminate/Container/Container.php(734): Illuminate\Container\Cont in /var/www/rafdev.ovh/html/msvixen/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 737
Script php artisan clear-compiled handling the post-update-cmd event returned with an error



  [RuntimeException]                                                                                                                                                        
  Error Output: PHP Fatal error:  Uncaught exception 'ReflectionException' with message 'Class App\Console\Kernel does not exist' in /var/www/rafdev.ovh/html/msvixen/vend  
  or/laravel/framework/src/Illuminate/Container/Container.php:737                                                                                                           
  Stack trace:                                                                                                                                                              
  #0 /var/www/rafdev.ovh/html/msvixen/vendor/laravel/framework/src/Illuminate/Container/Container.php(737): ReflectionClass->__construct('App\Console\Ker...')              
  #1 /var/www/rafdev.ovh/html/msvixen/vendor/laravel/framework/src/Illuminate/Container/Container.php(627): Illuminate\Container\Container->build('App\Console\Ker...', Ar  
  ray)                                                                                                                                                                      
  #2 /var/www/rafdev.ovh/html/msvixen/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(674): Illuminate\Container\Container->make('App\Console\Ker...',   
  Array)                                                                                                                                                                    
  #3 /var/www/rafdev.ovh/html/msvixen/vendor/laravel/framework/src/Illuminate/Container/Container.php(216): Illuminate\Foundation\Application->make('App\Console\Ker...',   
  Array)                                                                                                                                                                    
  #4 /var/www/rafdev.ovh/html/msvixen/vendor/laravel/framework/src/Illuminate/Container/Container.php(734): Illuminate\Container\Cont in /var/www/rafdev.ovh/html/msvixen/  
  vendor/laravel/framework/src/Illuminate/Container/Container.php on line 737                                                                                               



update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--] [<packages>]...


root@websites:/var/www/rafdev.ovh/html/msvixen# 

这是我的composer.json文件

    {
      "name": "laravel/laravel",
      "description": "The Laravel Framework.",
      "keywords": [
        "framework",
        "laravel"
      ],
      "license": "MIT",
      "type": "project",
      "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.1.*",
        "skmetaly/laravel-twitch-restful-api": "dev-master",
        "laravelcollective/html": "5.*"
      },
      "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1"
      },
      "autoload": {
        "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": [

        ],
        "post-update-cmd": [
          "php artisan clear-compiled",
          "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"
      }
    }

推荐答案

要更好地理解这一点(简洁):Compiled.php相当于现有应用程序的快照映射.作曲家更新能够更改快照中映射的类的位置或存在性.发生这种情况时,compiled.php在其映射中找不到类. (这就是为什么'clear-compiled'应该几乎总是在pre-update-cmd块中运行的原因.)

To better understand this (succinctly): Compiled.php has what amounts to a snapshot map of your existing application. A composer update has the ability to change the location or existence of classes mapped in the snapshot. When this happens, compiled.php can't find the classes in its map. (This is why 'clear-compiled' should almost always be run in the pre-update-cmd block.)

此问题通常发生在升级或文件系统异常更改期间,这些错误本质上使Compiled.php无效.好消息是,有一种解决方法.

This problem generally happens during upgrades or abnormal file-system changes that essentially invalidate compiled.php. The good news is that there is a way around this.

如果只是被您自己编译的php.php搞砸了,您可以手动将其删除,然后再次尝试更新作曲家.通常,这是通过"php artisan clear-compiled"完成的,但是由于artisan使用Compiled.php,此命令会自行阻止.因此,需要手动删除compiled.php文件.

If it is just your compiled.php that is messed up, you can manually delete it and try the composer update again. This is normally done with "php artisan clear-compiled" but since artisan uses compiled.php, this command blocks itself. Hence the need to manually remove the compiled.php file.

$ rm bootstrap/cache/compiled.php
$ composer update

如果仍然遇到有关缺少类的错误,则意味着文件系统中还有其他地方可能缺少的内容.下一部分有些棘手,但是可以.

If you still get errors about missing classes, it means there's something missing in your filesystem that is expected elsewhere. This next part is a little tricky, but it works.

根据我在composer.json文件中查看的内容,您可能需要将"php artisan clear-compiled"命令从"post-update-cmd"移动到"pre-update-cmd" ' 堵塞.这样,在作曲家更新文件后,compiled.php文件就不会像上面描述的那样阻止工匠了.

Based on what I'm looking at in your composer.json file, you will likely need to move the "php artisan clear-compiled" command from the 'post-update-cmd' to the 'pre-update-cmd' block. This way the compiled.php file doesn't block artisan as described above after composer updates your files.

消除这种情况的完整过程是:

The full process for de-funking this situation is:

  1. 手动删除Compiled.php(通常在L5.1的/bootstrap/cache中)
  2. 确保在composer.json的"pre-update-cmd"块中没有运行任何手工命令(特别是对您来说,这不是问题)
  3. 运行作曲家更新
  4. 将所有已删除的artisan命令放回composer.json的"pre-update-cmd"块中(特别是对于您,只需将明确编译的内容从post移到pre).
  1. Manually delete compiled.php (usually in /bootstrap/cache for L5.1)
  2. Make sure no artisan commands are run in the "pre-update-cmd" block of your composer.json (for you specifically, this is not a problem)
  3. Run composer update
  4. Put back any removed artisan commands in the "pre-update-cmd" block of your composer.json (for you specifically, just move clear-compiled from post to pre)

如果您仍然遇到问题,请发表评论.

If you have continued issues, please comment.

这篇关于L5.1类App \ Console \ Kernel不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆