DEV Community

Discussion on: php - How to fix "Class '' not found" error

Collapse
 
trstaley profile image
trstaley • Edited

Mr. DeChamp,

Maybe you can help me. I have composer working in my MAMP environment. I successfully added a package and it is executing in my php code. I then copied the code folder, including the .json and .lock file into a new folder (the folder is at the same directory level as the original code folder). When I execute the new code folder, I get an error on one package that the class is not found.

Exception has occurred.
Error: Class 'BenMorel\GsmCharsetConverter\Converter' not found

Why would the exception occur on code in one folder but not the other? What is getting lost on the copy?

Ok, I solved my own problem, but not sure why what I did was necessary. So maybe you could educate me.

I ran php composer.phar update on the new directory and that corrected the problem. Why would one package require phar update be run, when the package ran on the folder it came from?

Any help would be greatly appreciated.

Also, I should have mentioned that there are not hardcoded directory paths in the app. All paths are relative.