L5.1 Class App \ Console \ Kernel不存在

时间:2015-11-17 15:47:46

标签: php laravel

每当我试图运行composer updaterequirephp artisan时,我都会收到错误

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"
      }
    }

2 个答案:

答案 0 :(得分:5)

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

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

如果只是你的compiled.php搞砸了,你可以手动删除它并再次尝试编辑器更新。这通常使用“php artisan clear-compiled”完成,但由于工匠使用的是compile.php,因此该命令会阻止自身。因此需要手动删除compiled.php文件。

.grid-single .grid-content {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: #1ABC9C;
    opacity: 0;
    transition: opacity 0.1s;
    text-align:left;
}

.grid-single .grid-content span {
    display: table;
    position:absolute;
    left:10%;
    width:80%;
    height:100%;
    text-align:center;
}

.hover-content {
    display:table-cell;
    background-color:#ff6600;
    vertical-align:middle;
}

如果您仍然遇到有关缺少类的错误,则意味着您的文件系统中缺少其他地方所需的内容。下一部分有点棘手,但它确实有效。

基于我在你的composer.json文件中看到的内容,你可能需要将“php artisan clear-compiled”命令从'post-update-cmd'移到'pre-update-cmd '阻止。这样,在作曲家更新文件后,compiled.php文件不会像上面所描述的那样阻止工匠。

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

  1. 手动删除compiled.php(通常在L5.1的/ bootstrap / cache中)
  2. 确保在composer.json的“pre-update-cmd”块中没有运行工匠命令(具体来说,这不是问题)
  3. 运行composer update
  4. 在composer.json的“pre-update-cmd”块中放回任何删除的工匠命令(具体来说,只需将清除编译从post移到pre)
  5. 如果您有问题,请发表评论。

答案 1 :(得分:0)

问题在于命名空间。我甚至没有意识到它是这样的,之前我使用过php artisan app:name myname,它更新了文件,但它没有更新composer.json文件。所以我还原了它改变命名空间的每个文件 - 现在它可以工作。

愚蠢但耗费时间......