Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincej's avatar
Level 15

Upgrading to L5 and getting "Class Not Found" on composer update

I've been following the instructions given on the Laravel site for upgrading 4.2 to 5.

When I run composer update I get a fatal error - any ideas what I could be doing wrong ?

Generating autoload files
PHP Fatal error:  Class 'Auburntree\Providers\RouteServiceProvider' not found in /var/www/auburntree/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 150
exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Class 'Auburntree\Providers\RouteServiceProvider' not found' in /var/www/auburntree/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:150
Stack trace:
#0 /var/www/auburntree/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(116): Illuminate\Foundation\Bootstrap\HandleExceptions->fatalExceptionFromError(Array)
#1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleShutdown()
#2 {main}
Script php artisan clear-compiled handling the post-update-cmd event returned with an error

It feel to me that there is something wrong in my json file autoload files. The curious thing is that "RouteServiceProvider" is there under auburntree/app/providers. I think I have set things up according to the L5 instructions:

"autoload": {
        "classmap": [
            "database",
          "app/Http/Controllers",
          "app/source"
        ],
        "psr-4": {
            "Auburntree\\": "app/"
        }
    },

I have also noticed that an PHPStorm is complaining about this taken from IlluminateQueueCloser.php:

public function fire($job, $data)
    {
        $closure = unserialize($this->crypt->decrypt($data['closure']));

        $closure($job);    // $closure is red underlined
    }
0 likes
46 replies
vincej's avatar
Level 15

Tried it and I get the identical same error.

bestmomo's avatar

Maybe you need this :

        "psr-4": {
            "Auburntree\\": "app/Auburntree"
        }
vincej's avatar
Level 15

@bashy

Hi @bestmomo - ok, I decided to do a fresh install and start again. I am following the instructions given in the L5 manual for upgrading from L4.2. Clearly the author intended something very, very different than what I am doing, or alternatively they missed something out, for as written I can not get these instructions to work at all. @jeffreyway It would be great if you could speak to Taylor as these instructions just do not work - I have tried them probably 10 times. If they do work, then perhaps they could do with a rewrite, as mere mortals such as I can not get them to work :o)

At each and every step of the L5 upgrade instructions I stop and test to see if the Home view is presented so that I can at least isolate where things are going wrong. I have not added any of my own controllers. Everything is fine, right up to this section under "Controllers" :

Since we are not going to migrate to full namespacing in this guide, add the app/Http/Controllers directory to the classmap directive of your composer.json file. Next, you can remove the namespace from the abstract app/Http/Controllers/Controller.php base class. ...... In your app/Providers/RouteServiceProvider.php file, set the namespace property to null.

I have followed these exactly as written many, many times, and each time the homepage fails when you follow these instructions. In fact the home page fails when you remove the namespace from Controllers/Controller.php

I have made certain that I updated my classmap:

"autoload": {
        "classmap": [
            "database",
          "app/Http/Controllers"
        ],
"psr-4": {
            "App\\": "app/"
        }
    },

I have also tried changing the psr-4 as you suggested yesterday with no success.

Any ideas ???

bashy's avatar

So your files have the app:name set right? For example: <?php namespace Auburntree\Http;

vincej's avatar
Level 15

I set app:name to auburntree which in turn updated all my name spaces to auburntree\Http\Controllers; and psr-4 to

"psr-4": {
            "auburntree\\": "app/"
        }

However it had no impact on the system. I don't even get the home page now. I think I will reinstall for the ... 12th time :o)

vincej's avatar
Level 15

ok - so I reinstalled and I immediately changed the app:name to auburntree and it immediately stops functioning.

bashy's avatar

All fine here so you must be doing something wrong :)

Just make sure everything links up in the code/namespace and psr-4

vincej's avatar
Level 15

Exactly, for sure I am doing something wrong. I'm looking at Matt Stauffer's blog and there are differences with the L5 docs. If you follow the L5 upgrade docs meticulously they do not describe an approach which works. Docs which do not work for joe average are as useful as a chocolate teapot. They they need redrafting.

Even so much as changing app:name causes system failure. Same deal with clear-compile. In fact I am going to ignore the upgrade docs and just do an install like it was a virgin app. I think Jeffrey should do a video, but isn't doing one. So far I have spent a day and a half trying to get L5 working with my l4 code and no luck. Thanks for looking into this.

bashy's avatar

I haven't read the upgrade docs and I've just managed to get my old L4 admin backend unnamspaced controllers working in L5 in 2 hours while watching some Elementary :P

nolros's avatar

@vincej I had a similar problem. The clear complied would not work until I got the app up and running at least once. I would suggest remove reference to all SP's so you get it bare metal. Get it up and running, do a composer dump-autoload and then php artisan clear-compiled. Check to see that it works and then start adding them back in. Don't know what it is doing that, but that is how I got it work yesterday, because in my case it was a compile issue, but it would not clear it without me going through the above steps.

vincej's avatar
Level 15

@nolros @bashy @bestmomo

I really appreciate you guys helping out. I don't understand what you mean by "SP's" ( Service Providers ? )

Today several times I loaded a virgin / bare metal system. I always get a Welcome page off my directory, which I assume tells me apache is functioning fine. However if I even so much as simply change the name of app the system fails. So I check psr-4 and the name space of the Welcome controller and they line up. So I decide to roll it back to App again using app:name and now it will not deliver the home page even though the psr-4 lines up with the controllers.

L5 has a track record of problems with app:name: https://laracasts.com/discuss/channels/general-discussion/artisan-appname-no-longer-working https://github.com/laravel/framework/issues/5613

Really stuck. Can anyone think what I can try next ? or of any reason why L5 should fail after changing app:name?

Many thanks

@jeffreyway - Heah, Jeffrey, you have Taylor's home number. Please don't take this the wrong way - Can you let him know that there still appears to be a real problem with the docs and maybe even the code. Cheers :o)

nolros's avatar

Vince, what I'm saying is the following:

  1. install a fresh copy.
  2. don't do anything other basic maybe DB setup. Just get it up and running.
  3. once you get the welcome screen then. Go to command line run
// step 1
composer self-update

// step 2
composer dump-autoload

// step 3
php artisan clear-compiled

// step 4
load the home page again the browser and any other views that come with the app. 
// note I went in and made a little adjustment to a view to get it to compile  

then start by manually touching your config.files and keep running step 2 and 3 as you go along. Somewhere along the line the block clears and it all works again. I think it has something to do with the view render code, but unsure what it is as now it works fine so cannot troubleshoot.

Yes, SP = Service Providers.

Hope that helps.

vincej's avatar
Level 15

@nolros Heah Cheers and Many Thanks I'll try it first thing tomorrow!! Either you are up late or up early ! :o)

zefman's avatar

I had this issue as well. I got around it by manually deleting the compiled files in storage>framework. The issue was the php artisan clear-compiled was failing before it could actually get rid of the files. It could be the same issue for you :)

vincej's avatar
Level 15

@nolros I'm also MST - Calgary ! Where are you, Colorado ?

I am so grateful for the efforts of you and @bashy and @bestmomo - without people like you I'd never get it together.

I use Ubuntu with Apache installed manually, no mamp. Many thanks

vincej's avatar
Level 15

@nolros

Hi - well, I followed the prescribed steps, and it all works until I get to #3 clear-compiled at which point the welcome screen disappears just like yesterday. However you have helped me establish that it has nothing to do with psr-4 or namespaces or such like.

Ok, so I looked into my apache ini file with the stackoverflow doc, and opcache.revalidate_freq=60 was commented out. I tried setting it to "0" with no effect.

You know, I am starting to believe that L5 has been released too early. It does not appear to be ready for prime time. I'm not the greatest developer but I am no fool either. Call me old fashioned, but in my view a product should work out of the box.

Nolros - you are a mega star ! Thanks again.

vincej's avatar
Level 15

@zefman

Hi - thanks for your help. I deleted the compiled files from framework/views and sadly it didn't help - bummer.

vincej's avatar
Level 15

What does a person have to do to have a s/w flaw recognised as real ... just reported the problem on Github and was told that it was not real and could I go back to the forums .... I'm very surprised by the denial. Not what I expected from Laravel.

bestmomo's avatar

There is something strange with storage/framework/service.json. I've had some issues when just moving provider reference in list. I've had to clear many times this file to get application working. But now I cant reproduce the phenomenon so I wonder...

bashy's avatar

@vincej Yeah without being able to reproduce the issue I don't think they will have time to listen to problems that could well be user error.

Have you narrowed down the point in which it fails? Is it hard to follow the code and see which part is going wrong?

vincej's avatar
Level 15

@bashy You bet I have narrowed it down. Nolros offered me a very, very simple multi point plan featured on the previous page. I followed it meticulously and reported in a post above that it fails on #3 - take a look. Essentially, as soon as you hit clear-compile, it fails. It also fails if you use app:name. And additionally it also fails when you apply the official instructions as given in the 4.2 > 5 upgrade instructions under "Controllers".

I had an interesting dialogue today with Graham Campbell. Graham Campbell is on the official dev team He also is only 2nd to Taylor in terms of commits. Graham is 17. I consider you, @bestmomo and @nolros amongst the very best developers around. This is what he had to say about using app:name, something which Jeffrey teaches:

Graham Campbell:

To be totally honest, I'd never recommend people to use the app:name command due to how it works .....app:name is rubbish by design imo. Tests wouldn't help there .... I'm telling you my honest opinion. I wouldn't use it.

And on the topic of clear-compiled:

the clear-compiled command will of course fail if the compiled file is dodgy. That's been an issue since 4.0.

so.. I'm not the greatest dev in the world, but I am no fool either. I need stuff to work out of the box, and with docs that are relevant. I'd still prefer to use L5 than L4.

As always Many thanks

1 like
brunog's avatar

Hey @vincej seems that you've figured the issue out :)

Fyi, he's 2nd to Taylor on commits but keep in mind that the commits are mostly Coding Standards fixes (fix space here, fix typo there).

Take care.

vincej's avatar
Level 15

Hi @brunog Thanks again for your offer of help. Nope I have not figured anything out.

cheers

vincej's avatar
Level 15

yes - 3 paragraphs from the top I give nolros my findings. His plan did not work.

Portugal eh .. I used to come from England. It's very late there. Many thanks !

brunog's avatar

Did you tried to remove the storage/framework/compiled.php file manually?

brunog's avatar

Yeah, it's 3am here, but i'm used to work late, so no biggie :)

vincej's avatar
Level 15

Wow ! I live in Canada now - 8.25 pm

Yup deleted storage/framework/compiled.php

Zefman suggested that at the top of the page and sadly it didn't work.

Next

Please or to participate in this conversation.