Fix this error
PHP: Class not found
Dasun Kalupahana 300 views
The error
Error
Error: Class "App\Services\PaymentService" not found
Why it happens
Composer's autoloader cannot find a file for that class. Usually:
- The namespace does not match the folder (
App\Servicesmust be inapp/Services). - The file or class name differs in case. Windows ignores it, Linux servers don't.
- The
usestatement is missing or wrong. - The class came with a new package and
composer installwas not run.
How to fix it
- Check that the namespace, the folder and the file name match, including upper and lower case.
- Add or fix the
useline where the class is used. - Regenerate the autoloader.
composer dump-autoload
# a package class? install dependencies
composer install
Still stuck? Send us the full error and what you tried. We add the answers here.