Reputation: 51
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#
and this is my composer.json
file
{
"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"
}
}
Upvotes: 1
Views: 7647
Reputation: 51
The problem was with namespaces. I didn't even realize it was it, I used php artisan app:name myname
before, and it updated files, but it didn't update composer.json
file. So I reverted every file that it changed namespace in - and now it works.
Silly but how time consuming...
Upvotes: 0
Reputation: 2016
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.)
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.
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.
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:
If you have continued issues, please comment.
Upvotes: 6