'How to fix laravel composer update issue ( Illuminate\Foundation\ComposerScripts::postAutoloadDump failed to open stream: No such file or directory)

I'm currently working on a laravel project using an existing package for e-commerce functionality called Bagisto. I already downloaded the package files from the repository on GitHub and dopped the files inside xampp htdocs folder on my Ubuntu 18.04 OS. The problem happens after I launch composer update in the terminal inside my project directory I get this error message:

Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
PHP Warning:  Uncaught ErrorException: require(/opt/lampp/htdocs/bagisto/vendor/composer/../guzzlehttp/guzzle/src/functions_include.php): failed to open stream: No such file or directory in /opt/lampp/htdocs/bagisto/vendor/composer/autoload_real.php:66
Stack trace:
#0 /opt/lampp/htdocs/bagisto/vendor/composer/autoload_real.php(66): Composer\Util\ErrorHandler::handle(2, 'require(/opt/la...', '/opt/lampp/htdo...', 66, Array)
#1 /opt/lampp/htdocs/bagisto/vendor/composer/autoload_real.php(66): require()
#2 /opt/lampp/htdocs/bagisto/vendor/composer/autoload_real.php(56): composerRequire75e2944913aa928a280073a462abdd28('37a3dc5111fe8f7...', '/opt/lampp/htdo...')
#3 /opt/lampp/htdocs/bagisto/vendor/autoload.php(7): ComposerAutoloaderInit75e2944913aa928a280073a462abdd28::getLoader()
#4 /opt/lampp/htdocs/bagisto/vendor/laravel/framework/src/Illuminate/Foundation/ComposerScripts.php(43): require_once('/opt/lampp/htdo...')
#5 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(297): Illuminate\Foundation\C in /opt/lampp/htdocs/bagisto/vendor/composer/autoload_real.php on line 66

Warning: Uncaught ErrorException: require(/opt/lampp/htdocs/bagisto/vendor/composer/../guzzlehttp/guzzle/src/functions_include.php): failed to open stream: No such file or directory in /opt/lampp/htdocs/bagisto/vendor/composer/autoload_real.php:66
Stack trace:
#0 /opt/lampp/htdocs/bagisto/vendor/composer/autoload_real.php(66): Composer\Util\ErrorHandler::handle(2, 'require(/opt/la...', '/opt/lampp/htdo...', 66, Array)
#1 /opt/lampp/htdocs/bagisto/vendor/composer/autoload_real.php(66): require()
#2 /opt/lampp/htdocs/bagisto/vendor/composer/autoload_real.php(56): composerRequire75e2944913aa928a280073a462abdd28('37a3dc5111fe8f7...', '/opt/lampp/htdo...')
#3 /opt/lampp/htdocs/bagisto/vendor/autoload.php(7): ComposerAutoloaderInit75e2944913aa928a280073a462abdd28::getLoader()
#4 /opt/lampp/htdocs/bagisto/vendor/laravel/framework/src/Illuminate/Foundation/ComposerScripts.php(43): require_once('/opt/lampp/htdo...')
#5 phar:///usr/local/bin/composer/src/Composer/EventDispatcher/EventDispatcher.php(297): Illuminate\Foundation\C in /opt/lampp/htdocs/bagisto/vendor/composer/autoload_real.php on line 66
PHP Fatal error:  composerRequire75e2944913aa928a280073a462abdd28(): Failed opening required '/opt/lampp/htdocs/bagisto/vendor/composer/../guzzlehttp/guzzle/src/functions_include.php' (include_path='.:/usr/share/php') in /opt/lampp/htdocs/bagisto/vendor/composer/autoload_real.php on line 66

Fatal error: composerRequire75e2944913aa928a280073a462abdd28(): Failed opening required '/opt/lampp/htdocs/bagisto/vendor/composer/../guzzlehttp/guzzle/src/functions_include.php' (include_path='.:/usr/share/php') in /opt/lampp/htdocs/bagisto/vendor/composer/autoload_real.php on line 66

And the composer.json file content is:

{
    "name": "bagisto/bagisto",
    "description": "Bagisto Laravel ECommerce",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": "^7.1.3",
        "barryvdh/laravel-dompdf": "^0.8.0@dev",
        "dimsav/laravel-translatable": "^9.0",
        "doctrine/dbal": "^2.9@dev",
        "fideloper/proxy": "^4.0",
        "flynsarmy/db-blade-compiler": "*",
        "intervention/image": "^2.4",
        "intervention/imagecache": "^2.3",
        "kalnoy/nestedset": "^4.3",
        "konekt/concord": "^1.2",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0",
        "maatwebsite/excel": "3.1.x-dev",
        "nwidart/laravel-modules": "^3.2",
        "prettus/l5-repository": "^2.6",
        "propaganistas/laravel-intl": "^2.0"
    },
    "require-dev": {
        "barryvdh/laravel-debugbar": "^3.1",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpro/grumphp": "dev-master",
        "phpunit/phpunit": "^7.0"
    },
    "replace": {
        "bagisto/laravel-user": "v0.1.0",
        "bagisto/laravel-admin": "v0.1.0",
        "bagisto/laravel-ui": "v0.1.0",
        "bagisto/laravel-core": "v0.1.0",
        "bagisto/laravel-attribute": "v0.1.0",
        "bagisto/laravel-checkout": "v0.1.0",
        "bagisto/laravel-customer": "v0.1.0",
        "bagisto/laravel-inventory": "v0.1.0",
        "bagisto/laravel-category": "v0.1.0",
        "bagisto/laravel-product": "v0.1.0",
        "bagisto/laravel-shop": "v0.1.0",
        "bagisto/laravel-theme": "v0.1.0",
        "bagisto/laravel-shipping": "v0.1.0",
        "bagisto/laravel-payment": "v0.1.0",
        "bagisto/laravel-sales": "v0.1.0",
        "bagisto/laravel-tax": "v0.1.0"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/",
            "Webkul\\User\\": "packages/Webkul/User/src",
            "Webkul\\Admin\\": "packages/Webkul/Admin/src",
            "Webkul\\Ui\\": "packages/Webkul/Ui/src",
            "Webkul\\Category\\": "packages/Webkul/Category/src",
            "Webkul\\Checkout\\": "packages/Webkul/Checkout/src",
            "Webkul\\Attribute\\": "packages/Webkul/Attribute/src",
            "Webkul\\Shop\\": "packages/Webkul/Shop/src",
            "Webkul\\Core\\": "packages/Webkul/Core/src",
            "Webkul\\Customer\\": "packages/Webkul/Customer/src",
            "Webkul\\Inventory\\": "packages/Webkul/Inventory/src",
            "Webkul\\Product\\": "packages/Webkul/Product/src",
            "Webkul\\Theme\\": "packages/Webkul/Theme/src",
            "Webkul\\Shipping\\": "packages/Webkul/Shipping/src",
            "Webkul\\Payment\\": "packages/Webkul/Payment/src",
            "Webkul\\Paypal\\": "packages/Webkul/Paypal/src",
            "Webkul\\Sales\\": "packages/Webkul/Sales/src",
            "Webkul\\Tax\\": "packages/Webkul/Tax/src",
            "Webkul\\API\\": "packages/Webkul/API"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://packagist.org"
        },
        {
            "packagist": false
        }
    ],
    "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",
            "App\\Test::test",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "stable",
        "sort-packages": true,
        "optimize-autoloader": true
    },
    "minimum-stability": "dev"
}

I already tried some ways to resolve this problem like updating the composer and the laravel framework version but still not getting any solution.



Solution 1:[1]

If the answer of Ankit Singh not working.

  • You had run composer install and you got a general error in terminal window, for example: Illuminate\Foundation\ComposerScripts::postAutoloadDump failed to ............
  • If you have a bad syntax into your php files code (like a wrong use Class; statement) then the error above not show much details.
  • Try to run php artisan migrate, and then will show where the problem is with full path and the line number of the problematic file. (for example: Warning: The use statement with non-compound name 'Log' has no effect in \path\to\your\file.php on line 5)
  • So, with that detailed error we can go to specific file and resolve the problem (in this case, remove use Class from php class includes)

    Hope someone find help in this!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1