bertmi01's avatar

Composer - "Could not scan for classes inside..."

So I've been having a nightmare of a time with Composer and can't find a solution anywhere. I'm not at all an experienced developer so any help would be sincerely appreciate!

I have an app on Laravel 5.8 I needed to update and when I went to add a new package, I ran into the "composer memory limit" issue. Updating to version 2 seemed to fix it, but now when I try to update my dependencies, I keep running into:

 [RuntimeException]
  Could not scan for classes inside "C:\laragon\www\test\vendor/phpunit/php-code-coverage/src/" which does not appear to be a file nor a folder  


Exception trace:
 () at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/ClassMapGenerator.php:71
 Composer\Autoload\ClassMapGenerator::createMap() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/AutoloadGenerator.php:395
 Composer\Autoload\AutoloadGenerator->generateClassMap() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/AutoloadGenerator.php:381
 Composer\Autoload\AutoloadGenerator->addClassMapCode() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Autoload/AutoloadGenerator.php:277
 Composer\Autoload\AutoloadGenerator->dump() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Installer.php:314
 Composer\Installer->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Command/InstallCommand.php:131
 Composer\Command\InstallCommand->execute() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Command/Command.php:245
 Symfony\Component\Console\Command\Command->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Application.php:835
 Symfony\Component\Console\Application->doRunCommand() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Application.php:185
 Symfony\Component\Console\Application->doRun() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Console/Application.php:310
 Composer\Console\Application->doRun() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/vendor/symfony/console/Application.php:117
 Symfony\Component\Console\Application->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Console/Application.php:122
 Composer\Console\Application->run() at phar://C:/ProgramData/ComposerSetup/bin/composer.phar/bin/composer:63
 require() at C:\ProgramData\ComposerSetup\bin\composer.phar:24

I've tried deleting my vendor folder followed by "composer clearcache" and running update, but no luck.

If this additional info helps, I also tried moving to wamp and laragon from xampp while trying to fix the memory limit issue, which means I'm also trying to work with setting up the app locally again from my repo. As a result I can't run "composer dump-autoload":

PS C:\laragon\www\test> composer dump-autoload
Generating optimized autoload files
Class Illuminate\Foundation\ComposerScripts is not autoloadable, can not call post-autoload-dump script
> @php artisan package:discover

Fatal error: Uncaught Error: Class 'Illuminate\Foundation\Application' not found in C:\laragon\www\test\bootstrap\app.php:14
Stack trace:
#0 C:\laragon\www\test\artisan(20): require_once()
#1 {main}
  thrown in C:\laragon\www\test\bootstrap\app.php on line 14
PHP Fatal error:  Uncaught Error: Class 'Illuminate\Foundation\Application' not found in C:\laragon\www\test\bootstrap\app.php:14
Stack trace:
#0 C:\laragon\www\test\artisan(20): require_once()
#1 {main}
  thrown in C:\laragon\www\test\bootstrap\app.php on line 14
Script @php artisan package:discover handling the post-autoload-dump event returned with error code 255

So I don't know if one issue is causing the other or vice-versa. Any help would be sincerely appreciated since I'm completely at a loss and need to be able to update this site soon.. Thank you!

0 likes
11 replies
Snapey's avatar

I would definitely persevere via removing vendor folder, but also remove composer.lock and then run composer install.

bertmi01's avatar

Unfortunately the same result. I tried both:

  • delete vendor
  • delete composer.lock
  • composer clearcache
  • composer install (and another attempt with "composer install --no-scripts)

Is it possible I may have screwed up composer somehow?

Snapey's avatar

what error are you getting with the above?

bertmi01's avatar
 [RuntimeException]
  Could not scan for classes inside "C:\laragon\www\test\vendor/phpunit/php-code-coverage/src/" which does not appear to be a file nor a folder  

Basically all folders in vendor are empty as well.

Snapey's avatar

anything unusual in composer.json ?

bertmi01's avatar

I don't think so, but I also wouldn't know:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": "^7.1.3",
        "doctrine/dbal": "^2.9",
        "fideloper/proxy": "^4.0",
        "guzzlehttp/guzzle": "^6.3",
        "hisorange/browser-detect": "^3.1",
        "laravel/framework": "5.8.*",
        "laravel/tinker": "^1.0",
        "league/flysystem-aws-s3-v3": "^1.0",
        "maatwebsite/excel": "^3.0",
        "spatie/db-dumper": "^2.11",
        "spatie/laravel-backup": "^5.11",
        "symfony/http-foundation": "~4.4.13"
    },
    "require-dev": {
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\": "app/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
            ]
        }
    },
    "scripts": {
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate"
        ],
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

Snapey's avatar

This looks suspect

    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },

one of my 5.8 projects has

    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
bertmi01's avatar

Well, I'm not sure what to try with that, I removed it but get the same result. I'm thinking I'll just have to try and build a new project and copy the logic over..

Snapey's avatar

I realised what I posted looks just like what you posted. This is because \\ in the code is displayed as \

Then I realised that the same is true of your posted json file, you probably also have \\ which is displaying as \

bertmi01's avatar
bertmi01
OP
Best Answer
Level 3

So I updated to composer 2.0.5 -> 2.0.6, did dump-autoload then update, and it worked fine? I'm glad it's working, but now I'm just terrified that this will happen again down the road..

1 like

Please or to participate in this conversation.