58

I'm following the official upgrade guide from 5.1 to 5.2. First sub-section says:

If you are installing a beta release of Laravel 5.2, add "minimum-stability": "beta" to your composer.json file.

Update your composer.json file to point to laravel/framework 5.2.*.

Add symfony/dom-crawler ~3.0 and symfony/css-selector ~3.0 to the require-dev section of your composer.json file.

Now, after I introduce the above changes and run composer update, I get the following error(s):

PHP Fatal error:  Class 'Illuminate\Routing\ControllerServiceProvider' not found 
in /home/vagrant/Code/myproject/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146

and

[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Illuminate\Routing\ControllerServiceProvider' not found

and

[RuntimeException]
Error Output: PHP Fatal error:  Class 'Illuminate\Routing\ControllerServiceProvider' not found in /home/vagrant/Code/myproject/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146

The errors are thrown after the update is done, and "Generating autoload files" takes place.

What might be wrong?

It does not look like a custom package issue, but a core one. Should I continue with the upgrade guide and run composer update AFTER all has been adjusted to suit the new framework version?

UPDATE

Running composer dump-autoload afterwards doesn't throw the errors described above. Still confusing, though.

Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
lesssugar
  • 15,486
  • 18
  • 65
  • 115
  • 3
    On a related note, future readers may want to check out [Laravel Shift](https://laravelshift.com) - an automated upgrade tool for Laravel projects. – Jason McCreary Dec 23 '15 at 20:11

6 Answers6

62

There is no Illuminate\Routing\ControllerServiceProvider any more.

If I were you, I would compare my app project to https://github.com/laravel/laravel/commits/develop, if you for example look at https://github.com/laravel/laravel/blob/develop/config/app.php you will see default providers for Laravel 5.2:

Illuminate\Auth\AuthServiceProvider::class,
Illuminate\Broadcasting\BroadcastServiceProvider::class,
Illuminate\Bus\BusServiceProvider::class,
Illuminate\Cache\CacheServiceProvider::class,
Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class,
Illuminate\Cookie\CookieServiceProvider::class,
Illuminate\Database\DatabaseServiceProvider::class,
Illuminate\Encryption\EncryptionServiceProvider::class,
Illuminate\Filesystem\FilesystemServiceProvider::class,
Illuminate\Foundation\Providers\FoundationServiceProvider::class,
Illuminate\Hashing\HashServiceProvider::class,
Illuminate\Mail\MailServiceProvider::class,
Illuminate\Pagination\PaginationServiceProvider::class,
Illuminate\Pipeline\PipelineServiceProvider::class,
Illuminate\Queue\QueueServiceProvider::class,
Illuminate\Redis\RedisServiceProvider::class,
Illuminate\Auth\Passwords\PasswordResetServiceProvider::class,
Illuminate\Session\SessionServiceProvider::class,
Illuminate\Translation\TranslationServiceProvider::class,
Illuminate\Validation\ValidationServiceProvider::class,
Illuminate\View\ViewServiceProvider::class,
/*
 * Application Service Providers...
 */
App\Providers\AppServiceProvider::class,
App\Providers\AuthServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
Marcin Nabiałek
  • 109,655
  • 42
  • 258
  • 291
  • 1
    Does this mean I can safely remove the entry from config/app.php? – lesssugar Dec 21 '15 at 13:46
  • It seems yes, but you should make sure the entire structure and file contents of `app` folder matches the new one from Laravel 5.2 – Marcin Nabiałek Dec 21 '15 at 13:51
  • OK, thanks. The upgrade guide actually tells me to remove it in the Service Providers section. Guess it's better to update composer dependencies after all the code and structure had been adjusted. – lesssugar Dec 21 '15 at 13:55
  • Illuminate\Routing\ControllerServiceProvider::class and Illuminate\Foundation\Providers\ArtisanServiceProvider::class should be removed in 5.2 – gradosevic Dec 22 '15 at 09:51
  • 1
    @lesssugar yeah the upgrade instructions are ordered strangely – andrewtweber Dec 22 '15 at 18:48
  • 4
    So what if you have removed them but its still looking for them? I think they may be cached as they are in my bootstrap/cache/services.json – Bill Garrison Dec 24 '15 at 17:07
  • I tried for many times, eventually I comment out `App\Providers\RouteServiceProvider::class,` and run `composer update`. only it works – Js Lim Jun 01 '16 at 05:03
22

Remove the two service providers from config/app.php

Illuminate\Foundation\Providers\ArtisanServiceProvider::class,
 Illuminate\Routing\ControllerServiceProvider::class,
Jinu P C
  • 3,146
  • 1
  • 20
  • 29
21

In updating from 5.1 to 5.2 on existing projects, we found that running composer update before and after the removing the lines for the providers

Illuminate\Routing\ControllerServiceProvider::class Illuminate\Foundation\Providers\ArtisanServiceProvider::class

was a necessary sequence to getting the laravel update to complete.

Running before would allow laravel to download and update the current framework library dependencies and then running after the removal (composer was able to complete without issue)

We also found that any value in the .env file cannot have spaces and must be surrounded with quotes to work.

iowatiger08
  • 1,892
  • 24
  • 30
10

Updating the app.php file under config/ solved one problem but with the introduction of the bootstrap/cache folder you will probably continue running into the same error.

I ran the composer update Before removing the cached file so I kept hitting the same error. Make sure that you delete the bootstrap/cache/services.php file first.

There might be a artisan command for this but I totally missed this step in the documentation.

Adam Patterson
  • 651
  • 5
  • 11
  • 1
    Thats help, use rm bootstrap/cache/*.php fix my error – JS Lee May 06 '16 at 08:41
  • This answer led me to solve my issue. Just removing services.php, I still got the error. What I had to do was also remove bootstrap/cache/compile.php. Everything was working fine on my localhost but not on a live server, removing these 2 cached files solved my issue. Thanks @adam! – JustLearninThisStuff Dec 30 '18 at 01:41
3

I found the solution here:

https://laravel.com/docs/5.2/upgrade#upgrade-5.2.0

Service Providers

The Illuminate\Foundation\Providers\ArtisanServiceProvider should be removed from your service provider list in your app.php configuration file.

The Illuminate\Routing\ControllerServiceProvider should be removed from your service provider list in your app.php configuration file.

Erhnam
  • 901
  • 2
  • 13
  • 23
2

Remove packages.php and config.php from the bootstrap cache folder after run composer dump-autoload

Daniel Ortegón
  • 315
  • 2
  • 8