0
votes

Laravel version 5.6

I'm attempting to add some classes to my project via files under autoload.

Composer.json

"autoload": {
    "classmap": [
        "database/seeds",
        "database/factories"
    ],
    "psr-4": {
        "App\\": "app/"
    },
    "files" : [
        "app/helpers/dbUsers.php",
        "app/helpers/dbMoodChart.php"
    ]
},

Whenever I do a composer dump-autoload i get errors on both files saying files not found.

PHP Warning: Uncaught ErrorException: require(C:\laravel-projects\project\vendor\composer/../../app/helpers/dbUsers.php): failed to open stream: No such file or directory in C:\laravel-projects\project\vendor\composer\autoload_real.php:66 Stack trace:

Warning: Uncaught ErrorException: require(C:\laravel-projects\MoodWatch\vendor\composer/../../app/helpers/dbUsers.php): failed to open stream: No such file or directory in C:\laravel-projects\MoodWatch\vendor\composer\autoload_real.php:66 Stack trace:

The strange thing is its trying to load the files from the composer directory not the apps root folder. I've done this in another project and didn't have any issues. I've also compared my composer.json autoload sections on both projects and I can't see any syntax differences so I'm a bit puzzled as to why it's loading at the wrong location.

Has anyone seen anything similar before and be able to shed light on why it's doing this?

1
It does appear they're being loaded from the project dir, not composer - the /../../ in those paths look to be correctly ascending up 2 levesl from vendor/composer. Do the files have correct permissions to be visible to the web server service user? - Michael Berkowski
(I have no recent experience running PHP on windows to guide on how you would set perms) - Michael Berkowski
No the path is incorrect, at least to my understanding. The correct path is /project/app/helpers/files not vendor\composer/etc. - user873684

1 Answers

0
votes

I found out the name of the file had a typo and once fixed both errors went away