symfony / polyfill

PHP polyfills

Home Page:https://symfony.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

polyfill-php80/bootstrap.php could not be loaded by composer/autoload_real.php

talalong opened this issue · comments

I am having an issue while migrating from PHP7.4/Symfony 5.0 to PHP8.0 and Symfony 5.2. The composer update went through without any error was given. But trying to make some requests leads me to this error.

Warning: require(/app/vendor/composer/../symfony/polyfill-php80/bootstrap.php): Failed to open stream: No such file or directory in /app/vendor/composer/autoload_real.php on line 71

Fatal error: Uncaught Error: Failed opening required '/app/vendor/composer/../symfony/polyfill-php80/bootstrap.php' (include_path='.:/usr/local/lib/php') in /app/vendor/composer/autoload_real.php:71 Stack trace: #0 /app/vendor/composer/autoload_real.php(61): composerRequirefb4a0988f3721551a7eb12d6dfd89a25('a4a119a56e50fbb...', '/app/vendor/com...') #1 /app/vendor/autoload.php(12): ComposerAutoloaderInitfb4a0988f3721551a7eb12d6dfd89a25::getLoader() #2 /app/config/bootstrap.php(5): require('/app/vendor/aut...') #3 /app/public/index.p

There is no polyfill-php80 folder under the vendor/symfony folder.

Here is a snapshot of my composer.json.

{
  "name": "dummy",
  "config": {
    "preferred-install": {
      "*": "dist"
    },
    "sort-packages": true,
    "platform": {
      "php": "8.0"
    }
  },
  "require": {
    "ext-SimpleXML": "*",
    "ext-ctype": "*",
    "ext-iconv": "*",
    "ext-json": "*",
    "jms/serializer-bundle": "^3.5",
    "sensio/framework-extra-bundle": "^5.5",
    "symfony/console": "5.2.*",
    "symfony/dependency-injection": "5.2.*",
    "symfony/dotenv": "5.2.*",
    "symfony/flex": "1.9.*",
    "symfony/form": "5.2.*",
    "symfony/framework-bundle": "5.2.*",
    "symfony/monolog-bundle": "^3.5",
    "symfony/orm-pack": "2.1.*",
    "symfony/property-access": "5.2.*",
    "symfony/serializer": "5.2.*",
    "symfony/validator": "5.2.*",
    "symfony/yaml": "5.2.*"
  },
  "require-dev": {
    "phpunit/phpunit": "^9.3",
    "squizlabs/php_codesniffer": "^3.5.5",
    "symfony/maker-bundle": "^1.14",
    "friendsofphp/php-cs-fixer": "2.*",
    "phpmd/phpmd": "^2.8",
    "phpstan/phpstan": "0.12.*",
    "phpstan/phpstan-symfony": "0.12.*",
    "symfony/phpunit-bridge": "^5.1",
    "symfony/dom-crawler": "5.*",
    "symfony/css-selector": "5.*",
    "symfony/browser-kit": "5.*"
  },
  "autoload": {
    "psr-4": {
      "App\\": "src/"
    }
  },
  "autoload-dev": {
    "psr-4": {
      "App\\Tests\\": "tests/"
    }
  },
  "replace": {
    "paragonie/random_compat": "2.*",
    "symfony/polyfill-ctype": "*",
    "symfony/polyfill-iconv": "*",
    "symfony/polyfill-php80": "*",
    "symfony/polyfill-php74": "*"
  }
  "conflict": {
    "symfony/symfony": "*"
  },
  "extra": {
    "symfony": {
      "allow-contrib": false,
      "require": "5.2.*"
    }
  }
}

That's an issue with composer. Try removing your vendor dir and installing it again.

@nicolas-grekas I did. I have removed both vendor, var folders, and also composer.lock, symfony.lock files. It did not help.

Pulling a new PHP8 image (1.2.0) solved the problem.

Weird, I'm having the exact same issue, the file /vendor/symfony/polyfill-php80/bootstrap.php existed but it couldn't load the file for some reason. Currently using PHP 8.0.12 and it's the latest version available on my distro (Manjaro).

My error logs:

[Sat Nov 27 23:35:52.730308 2021] [php:warn] [pid 26995] [client 127.0.0.1:38996] PHP Warning:  require(/opt/lampp/htdocs/web/tabel_mhs/vendor/composer/../symfony/polyfill-php80/bootstrap.php): Failed to open stream: Permission denied in /opt/lampp/htdocs/web/tabel_mhs/vendor/composer/autoload_real.php on line 71, referer: http://localhost/web/tabel_mhs/index.html?
[Sat Nov 27 23:35:52.730501 2021] [php:error] [pid 26995] [client 127.0.0.1:38996] PHP Fatal error:  Uncaught Error: Failed opening required '/opt/lampp/htdocs/web/tabel_mhs/vendor/composer/../symfony/polyfill-php80/bootstrap.php' (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/web/tabel_mhs/vendor/composer/autoload_real.php:71\nStack trace:\n#0 /opt/lampp/htdocs/web/tabel_mhs/vendor/composer/autoload_real.php(61): composerRequireafcaf36851dbe63ac62baff873bf884f('a4a119a56e50fbb...', '/opt/lampp/htdo...')\n#1 /opt/lampp/htdocs/web/tabel_mhs/vendor/autoload.php(7): ComposerAutoloaderInitafcaf36851dbe63ac62baff873bf884f::getLoader()\n#2 /opt/lampp/htdocs/web/tabel_mhs/php/connect.php(5): require_once('/opt/lampp/htdo...')\n#3 /opt/lampp/htdocs/web/tabel_mhs/php/login.php(2): include('/opt/lampp/htdo...')\n#4 {main}\n  thrown in /opt/lampp/htdocs/web/tabel_mhs/vendor/composer/autoload_real.php on line 71, referer: http://localhost/web/tabel_mhs/index.html

My composer.json file (this error breaks MongoDB connection):

{
    "require": {
        "mongodb/mongodb": "^1.10"
    }
}

And my composer.lock file:

{
    "_readme": [
        "This file locks the dependencies of your project to a known state",
        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
        "This file is @generated automatically"
    ],
    "content-hash": "0cea1889f7ed529f5c37ce347714f05c",
    "packages": [
        {
            "name": "jean85/pretty-package-versions",
            "version": "2.0.5",
            "source": {
                "type": "git",
                "url": "https://github.com/Jean85/pretty-package-versions.git",
                "reference": "ae547e455a3d8babd07b96966b17d7fd21d9c6af"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/Jean85/pretty-package-versions/zipball/ae547e455a3d8babd07b96966b17d7fd21d9c6af",
                "reference": "ae547e455a3d8babd07b96966b17d7fd21d9c6af",
                "shasum": ""
            },
            "require": {
                "composer-runtime-api": "^2.0.0",
                "php": "^7.1|^8.0"
            },
            "require-dev": {
                "friendsofphp/php-cs-fixer": "^2.17",
                "jean85/composer-provided-replaced-stub-package": "^1.0",
                "phpstan/phpstan": "^0.12.66",
                "phpunit/phpunit": "^7.5|^8.5|^9.4",
                "vimeo/psalm": "^4.3"
            },
            "type": "library",
            "extra": {
                "branch-alias": {
                    "dev-master": "1.x-dev"
                }
            },
            "autoload": {
                "psr-4": {
                    "Jean85\\": "src/"
                }
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "MIT"
            ],
            "authors": [
                {
                    "name": "Alessandro Lai",
                    "email": "alessandro.lai85@gmail.com"
                }
            ],
            "description": "A library to get pretty versions strings of installed dependencies",
            "keywords": [
                "composer",
                "package",
                "release",
                "versions"
            ],
            "support": {
                "issues": "https://github.com/Jean85/pretty-package-versions/issues",
                "source": "https://github.com/Jean85/pretty-package-versions/tree/2.0.5"
            },
            "time": "2021-10-08T21:21:46+00:00"
        },
        {
            "name": "mongodb/mongodb",
            "version": "1.10.0",
            "source": {
                "type": "git",
                "url": "https://github.com/mongodb/mongo-php-library.git",
                "reference": "b0bbd657f84219212487d01a8ffe93a789e1e488"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/mongodb/mongo-php-library/zipball/b0bbd657f84219212487d01a8ffe93a789e1e488",
                "reference": "b0bbd657f84219212487d01a8ffe93a789e1e488",
                "shasum": ""
            },
            "require": {
                "ext-hash": "*",
                "ext-json": "*",
                "ext-mongodb": "^1.11.0",
                "jean85/pretty-package-versions": "^1.2 || ^2.0.1",
                "php": "^7.1 || ^8.0",
                "symfony/polyfill-php80": "^1.19"
            },
            "require-dev": {
                "doctrine/coding-standard": "^9.0",
                "squizlabs/php_codesniffer": "^3.6",
                "symfony/phpunit-bridge": "^5.2"
            },
            "type": "library",
            "extra": {
                "branch-alias": {
                    "dev-master": "1.10.x-dev"
                }
            },
            "autoload": {
                "psr-4": {
                    "MongoDB\\": "src/"
                },
                "files": [
                    "src/functions.php"
                ]
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "Apache-2.0"
            ],
            "authors": [
                {
                    "name": "Andreas Braun",
                    "email": "andreas.braun@mongodb.com"
                },
                {
                    "name": "Jeremy Mikola",
                    "email": "jmikola@gmail.com"
                }
            ],
            "description": "MongoDB driver library",
            "homepage": "https://jira.mongodb.org/browse/PHPLIB",
            "keywords": [
                "database",
                "driver",
                "mongodb",
                "persistence"
            ],
            "support": {
                "issues": "https://github.com/mongodb/mongo-php-library/issues",
                "source": "https://github.com/mongodb/mongo-php-library/tree/1.10.0"
            },
            "time": "2021-10-20T22:22:37+00:00"
        },
        {
            "name": "symfony/polyfill-php80",
            "version": "v1.23.1",
            "source": {
                "type": "git",
                "url": "https://github.com/symfony/polyfill-php80.git",
                "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be",
                "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be",
                "shasum": ""
            },
            "require": {
                "php": ">=7.1"
            },
            "type": "library",
            "extra": {
                "branch-alias": {
                    "dev-main": "1.23-dev"
                },
                "thanks": {
                    "name": "symfony/polyfill",
                    "url": "https://github.com/symfony/polyfill"
                }
            },
            "autoload": {
                "psr-4": {
                    "Symfony\\Polyfill\\Php80\\": ""
                },
                "files": [
                    "bootstrap.php"
                ],
                "classmap": [
                    "Resources/stubs"
                ]
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "MIT"
            ],
            "authors": [
                {
                    "name": "Ion Bazan",
                    "email": "ion.bazan@gmail.com"
                },
                {
                    "name": "Nicolas Grekas",
                    "email": "p@tchwork.com"
                },
                {
                    "name": "Symfony Community",
                    "homepage": "https://symfony.com/contributors"
                }
            ],
            "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions",
            "homepage": "https://symfony.com",
            "keywords": [
                "compatibility",
                "polyfill",
                "portable",
                "shim"
            ],
            "support": {
                "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1"
            },
            "funding": [
                {
                    "url": "https://symfony.com/sponsor",
                    "type": "custom"
                },
                {
                    "url": "https://github.com/fabpot",
                    "type": "github"
                },
                {
                    "url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
                    "type": "tidelift"
                }
            ],
            "time": "2021-07-28T13:41:28+00:00"
        }
    ],
    "packages-dev": [],
    "aliases": [],
    "minimum-stability": "stable",
    "stability-flags": [],
    "prefer-stable": false,
    "prefer-lowest": false,
    "platform": [],
    "platform-dev": [],
    "plugin-api-version": "2.1.0"
}

Already tried deleting vendor, composer.lock, clearing cache, and installing it again but it doesn't seem to fix the problem. Honestly, I'm already abandoning the project because of this but any help would be appreciated (planning on coming back later).

EDIT: Fixed by using sudo chmod -R 755 <path_to_vendor_folder>

Failed to open stream: Permission denied

This looks like a different error to me. Please don't use old bug reports for support questions. We have a discussions board for that: https://github.com/symfony/symfony/discussions/