Composer stops because a classmap path is missing on disk
Your error
Could not scan for classes inside "app/database/migrations" which does not appear to be a file nor a folder1 more line it can showFix it fast
Most common cause, 1 of 4A folder or file listed under classmap was renamed, moved or deleted
Change the entry to the folder's new location, or delete the entry if nothing there needs scanning, then rebuild the autoloader.
"autoload": {
"classmap": ["lib/legacy"]
}
composer dump-autoloadShort answer
Composer 2 scans every path listed under classmap and fails with could not scan for classes when one is neither a file nor a folder. The path names the case: a stale entry in composer.json, an empty folder Git never committed, an autoload-dev path missing in production, or an incomplete package in vendor. Fix the path and rebuild the autoloader.
Which cause do you have?
Take the path from the message and look for it in composer.json, then check whether it exists. A path that begins with vendor/ belongs to a package, not to your project.
grep -n -B2 -A8 '"classmap"' composer.json
ls -ld app/database/migrationsThen find the line you see in this list and open its fix:
- 1A folder or file listed under classmap was renamed, moved or deleted
The path is in your own composer.json, and ls reports No such file or directory - 2The folder is empty on your machine, so Git never stored it
Works on your laptop, fails right after a fresh git clone on the server or in CI - 3An autoload-dev path is missing from the production copy
The path is a tests or fixtures folder, and the deploy leaves that folder out (an rsync exclude, a .dockerignore line or an export-ignore rule) - 4A package in vendor is missing part of its files
The path in the message starts with vendor/, such as vendor/acme/foo/tests/Fixtures
What does the error look like?
Could not scan for classes inside "app/database/migrations" which does not appear to be a file nor a folderThe message appears at the end of composer install or composer update, or on composer dump-autoload
Cause 1 of 4
A folder or file listed under classmap was renamed, moved or deleted
You seeThe path is in your own composer.json, and ls reports No such file or directory
Check
Could not scan for classes inside a path taken from your own composer.json means a classmap entry points at a folder or file that was moved or deleted. Composer reads every directory and file in the classmap list and scans its .php and .inc files; its class map generator throws this exact error when an entry is neither an existing file nor a directory (entries containing a * wildcard are exempt).
grep -n -A8 '"classmap"' composer.json
for p in app/database/migrations app/database/seeds; do ls -ld "$p"; doneFix
Change the entry to the folder's new location, or delete the entry if nothing there needs scanning, then rebuild the autoloader.
"autoload": {
"classmap": ["lib/legacy"]
}
composer dump-autoloadVerify
dump-autoload runs to the end without a RuntimeException.
composer dump-autoloadConfirmed by raw.githubusercontent.com
Cause 2 of 4
The folder is empty on your machine, so Git never stored it
You seeWorks on your laptop, fails right after a fresh git clone on the server or in CI
Check
Could not scan for classes right after a fresh clone, while your own copy works, means the classmap folder is empty and was never committed. Git's index only lists files; a directory is not tracked on its own and appears in a checkout only when a file inside it is committed. An empty migrations or seeds folder therefore exists locally but not in the clone.
git ls-files app/database/seeds | head
git clone . /tmp/clone-check && ls -ld /tmp/clone-check/app/database/seedsFix
Commit a placeholder file in the folder, as the Git FAQ suggests for a directory that must exist in checkouts, or drop the entry from classmap if the folder will stay empty.
touch app/database/seeds/.gitkeep
git add app/database/seeds/.gitkeep
git commit -m "Keep seeds folder for the classmap"Verify
A new clone contains the folder and composer install runs to the end.
git ls-files app/database/seedsConfirmed by archive.kernel.org
Cause 3 of 4
An autoload-dev path is missing from the production copy
You seeThe path is a tests or fixtures folder, and the deploy leaves that folder out (an rsync exclude, a .dockerignore line or an export-ignore rule)
Check
Could not scan for classes on a production server, for a tests or fixtures path, means Composer is applying autoload-dev rules to a copy that left those folders out. Rules under autoload-dev are meant for development only; when the deploy drops a classmap folder listed there but Composer still runs in development mode, it tries to scan that folder and fails.
grep -n -A8 '"autoload-dev"' composer.jsonFix
Install in production with --no-dev. Composer then skips the require-dev packages and also leaves the autoload-dev rules out of the generated autoloader.
composer install --no-devVerify
The production install completes, and a later dump keeps the dev rules out explicitly.
composer dump-autoload --no-devConfirmed by getcomposer.org
Cause 4 of 4
A package in vendor is missing part of its files
You seeThe path in the message starts with vendor/, such as vendor/acme/foo/tests/Fixtures
Check
Could not scan for classes inside a vendor/ path means the classmap belongs to a dependency whose files on disk are incomplete. A dependency's classmap is resolved inside that package's folder, so a package with missing files (an interrupted install, a copied vendor folder, a cleanup script) triggers the same error. Compare the folder with what the package should contain.
ls -la vendor/acme/foo/Fix
Reinstall the package, or rebuild vendor from the lock file, which installs the exact locked versions again.
composer reinstall acme/foo
# or, for the whole tree
rm -rf vendor && composer installVerify
The path from the message now exists inside vendor and the install ends cleanly. If a clean reinstall still lacks it, the package's own release leaves that folder out and the fix belongs to its maintainers.
ls -ld vendor/acme/foo/tests/FixturesConfirmed by getcomposer.org
How do I stop it coming back?
- After moving or renaming any folder named under classmap, update composer.json and run composer dump-autoload in the same commit.
- For code you own, map namespaces with psr-4 instead of listing folders one by one.
- Keep tests and fixtures under autoload-dev and deploy with composer install --no-dev.
- Let CI run composer install from a fresh clone, so a directory present on just one developer machine breaks the build before it breaks a deploy.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: Spotless Laundry, EZ Estimater.