PHP Fatal error: Uncaught Error: Class "X" not found
PHP couldn’t load the class — autoloading failed, the namespace is wrong, or the dependency isn’t installed.
Seen on:
PHP
Meaning
Modern PHP relies on Composer’s PSR-4 autoloader. The class name (with namespace) must map to a file path that exists with matching case.
Common causes
vendor/missing —composer installnot run on server- Namespace/
usestatement wrong - File name or directory case differs from class (works on macOS, fails on Linux)
- Autoload map stale after adding classes
- Missing PHP extension providing the class (e.g.
PDO,ZipArchive)
⚡ Quick fix
- Run
composer install(andcomposer dump-autoload) - Check
usestatements and namespace declarations - Match file name case to class name exactly
- Enable the extension for built-in classes
Detailed fix by platform
PHP
composer dump-autoload -oafter adding classes; verifyautoload.psr-4in composer.json maps the namespace prefix to the right folder.
How to diagnose
- Name — Fully qualified class name correct?
- Autoload — Does PSR-4 map it to an existing file?
- Deploy — Is vendor/ present on the server?
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 2 Oct 2026