manix
manix

Reputation: 14747

Laravel ClassLoader includes an incorrect/old file

in a laravel 4 aplication some weeks ago I created a workbench package:

/workbench/no-native/wizard

This package has a class called Handler in the path /workbench/no-native/src/events/ declared like this:

<?php
namespace Wizard\events;

class Handler{

    ....

In order to dump-autoload via composer, I added it:

"autoload": {
    "classmap": [
        "src/migrations",
        "src/controllers",
        "src/events",
    ],
    "psr-0": {
        "NoNative\\Wizard\\": "src/"
    }
},

Well, with this structure the package worked very well. Yerterday, I had to move this package from workbench/no-native to workbench/native. The steps were the following:

  1. Move the wizard dir from no-native to native dir.
  2. Update paths and namespaces.
  3. Update the package composer to target the new file structure.
  4. Execute the following commands (in native, the new path):

    /home/user/public_html/my-app/workbench/native/wizard# composer update
    /home/user/public_html/my-app/workbench/native/wizard# composer dump-autoload
    

After finished, I notice that in my localhost instance the application works perfectly with the changes, but in my live server an exception is showed:

include(/home/user/public_html/my-app/workbench/no-native/wizard/src/events/Handler.php): failed to open stream: No such file or directory file: /home/user/public_html/my-app/vendor/composer/ClassLoader.php line 382

I assume that the application still trying to load the Handler class from old path. Then, I ran the commands in order to "clean" or "optimize" the application:

# php artisan optimize
# php artisan dump-autoload

And the exception still there. The live server has the same code of my localhost instance, because both work with cloned sources via Github. I do not know if I am missing something else. My last option is to create a new package via command, and then create the classes again. But before to do that, I would like to ask to you for alternative options.

Thank you in advance.

Upvotes: 4

Views: 2345

Answers (1)

Sumit Patil
Sumit Patil

Reputation: 556

Have you updated your packagist repository. Many times it does not auto update while pushing code to github so try to force update it. After this try to clear composer catche and then run php artisan dump-autoload.

Upvotes: 2

Related Questions