Fix this error
PHP: Class not found
Dasun Kalupahana 290 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.
Learn more on the blog
MySQL
PostgreSQL vs MySQL Performance: Real Benchmarks Compared
Last updated: 7 November 2026. See the update log at the end."Which...
8 min read
PHP
How to Detect and Fix PHP Memory Leaks
Last updated: 5 November 2026. See the update log at the end.In...
9 min read
Docker
Docker Build Too Slow? 10 Ways to Speed It Up
A slow Docker build usually has one of a few causes: you...
8 min read