sentry-symfony: Crash on install: missing nyholm/psr7 depencency

I did a a setup of your bundle following the documentation provided by the user interface:

composer require sentry/sentry-symfony

Then my project crash with the following error:

Symfony\Component\Debug\Exception\ClassNotFoundException:
Attempted to load class "Psr17Factory" from namespace "Nyholm\Psr7\Factory".
Did you forget a "use" statement for another namespace?

  at var/cache/dev/ContainerHgJCfth/getDebug_SensioFrameworkExtra_Psr7_ArgumentValueResolver_ServerRequestService.php:9
  at require()
     (var/cache/dev/ContainerHgJCfth/srcApp_KernelDevDebugContainer.php:877)
  at ContainerHgJCfth\srcApp_KernelDevDebugContainer->load('getDebug_SensioFrameworkExtra_Psr7_ArgumentValueResolver_ServerRequestService.php')
     (var/cache/dev/ContainerHgJCfth/srcApp_KernelDevDebugContainer.php:1851)
  at ContainerHgJCfth\srcApp_KernelDevDebugContainer->ContainerHgJCfth\{closure}()
     (vendor/php/symfony/http-kernel/Controller/ArgumentResolver.php:51)
  at Symfony\Component\HttpKernel\Controller\ArgumentResolver->getArguments(object(Request), array(object(HostingController), 'indexAction'))
     (vendor/php/symfony/http-kernel/Controller/TraceableArgumentResolver.php:38)
  at Symfony\Component\HttpKernel\Controller\TraceableArgumentResolver->getArguments(object(Request), array(object(HostingController), 'indexAction'))
     (vendor/php/symfony/http-kernel/HttpKernel.php:150)
  at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
     (vendor/php/symfony/http-kernel/HttpKernel.php:80)
  at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, true)
     (vendor/php/symfony/http-kernel/Kernel.php:201)
  at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
     (public/index.php:34)

I solved the issue just by adding the right package:

composer require nyholm/psr7

You may have to fix your dependencies definition.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

It could be nice to add in the UPGRADE note to add

sensio_framework_extra:
    psr_message:
        enabled: false

Unfortunately, I live in France, not in Theory. I wish I could go there. šŸ™ƒ

Here it is:

{
    "name": "xxx/xxx",
    "type": "project",
    "license": "proprietary",
    "autoload": {
        "psr-4": {
            "App\\": "src",
            "AppBundle\\": "src/AppBundle",
            "PowerDNSBundle\\": "src/PowerDNSBundle"
        },
        "files": [
            "src/env.php",
            "src/functions.php"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Dev\\": "src-dev/",
            "Tests\\AppBundle\\": "tests/AppBundle",
            "Tests\\PowerDNSBundle\\": "tests/PowerDNSBundle",
            "App\\Tests\\": "tests/"
        },
        "files": [
            "src/env_dev.php"
        ]
    },
    "require": {
        "php": "^7.4",
        "ext-PDO": "^7.1",
        "ext-bcmath": "^7.3",
        "ext-dom": "20031129",
        "ext-filter": "^7.1",
        "ext-hash": "^7.3",
        "ext-intl": "^7.3",
        "ext-json": "^7.4",
        "ext-openssl": "^7.1",
        "a2lix/translation-form-bundle": "^3.0",
        "algatux/influxdb-bundle": "^2.3",
        "api-platform/api-pack": "^1.1",
        "api-platform/core": "^2.3.5",
        "behat/transliterator": "^1.2",
        "browscap/browscap-bundle": "^1.0",
        "browscap/browscap-php": "^2.1",
        "cebe/markdown": "^1.1",
        "digitick/sepa-xml": "^1.0",
        "doctrine/annotations": "^1.6",
        "doctrine/cache": "^1.7",
        "doctrine/collections": "^1.5",
        "doctrine/common": "^2.9",
        "doctrine/dbal": "^2.6",
        "doctrine/doctrine-bundle": "^1.6",
        "doctrine/doctrine-cache-bundle": "^1.3",
        "doctrine/doctrine-migrations-bundle": "^1.0",
        "doctrine/event-manager": "^1.0",
        "doctrine/inflector": "^1.3",
        "doctrine/migrations": "^1.6",
        "doctrine/orm": "^2.6",
        "doctrine/persistence": "^1.0",
        "egulias/email-validator": "^2.1",
        "eightpoints/guzzle-bundle": "^7.3",
        "emojione/emojione": "^4.0",
        "endroid/qr-code-bundle": "^3.3",
        "exsyst/swagger": "^0.4.0",
        "fabpot/goutte": "^3.0",
        "fig/link-util": "^1.0",
        "friendsofsymfony/jsrouting-bundle": "^2.1",
        "friendsofsymfony/user-bundle": "^2.0",
        "fusionauth/fusionauth-client": "^1.16",
        "giggsey/libphonenumber-for-php": "^8.9",
        "greg0ire/enum": "^4.0",
        "gregwar/image-bundle": "^2.1, >2.1.3",
        "guzzlehttp/guzzle": "^6.0",
        "hackzilla/password-generator": "^1.4",
        "hackzilla/password-generator-bundle": "^3.0",
        "hautelook/alice-bundle": "^2.0",
        "incenteev/composer-parameter-handler": "^2.0",
        "influxdb/influxdb-php": "^1.14",
        "inlinestyle/inlinestyle": "^1.2",
        "internations/solr-utils": "^0.8",
        "jms/translation-bundle": "^1.4",
        "knplabs/doctrine-behaviors": "^1.4",
        "knplabs/knp-components": "^1.3",
        "knplabs/knp-markdown-bundle": "^1.3",
        "knplabs/knp-menu": "^2.3",
        "knplabs/knp-menu-bundle": "^2.0",
        "knplabs/knp-paginator-bundle": "^2.4.3",
        "knpuniversity/oauth2-client-bundle": "^2.1",
        "kriswallsmith/spork": "^0.3",
        "lstrojny/fxmlrpc": "^0.15",
        "mck89/peast": "^1.8",
        "misd/phone-number-bundle": "^1.2",
        "monolog/monolog": "^1.23",
        "mtdowling/cron-expression": "^1.1",
        "nelmio/alice": "^3.4",
        "nesbot/carbon": "^2.37",
        "netresearch/jsonmapper": "^1.4",
        "nexylan/cloudflare": "^0.3",
        "nexylan/cloudflare-host-gw": "^0.2",
        "nexylan/gandi-sdk": "^0.4",
        "nexylan/graylog-sdk": "^0.6",
        "nexylan/nexycrypt": "^0.8.0",
        "nexylan/paybox-direct": "^0.3.7",
        "nexylan/slack": "^2.2",
        "nexylan/slack-bundle": "^2.1",
        "nyholm/psr7": "^1.3",
        "ornicar/gravatar-bundle": "^1.2",
        "paragonie/constant_time_encoding": "^2.3",
        "patchwork/utf8": "^1.3",
        "php-http/cache-plugin": "^1.5",
        "php-http/client-common": "^2.0",
        "php-http/guzzle6-adapter": "^2.0",
        "php-http/httplug": "^2.0",
        "php-http/httplug-bundle": "^1.11",
        "predis/predis": "^1.0",
        "psr/http-message": "^1.0",
        "psr/log": "^1.0",
        "psr/simple-cache": "^1.0",
        "ramsey/uuid": "^4.0",
        "rollerworks/password-strength-bundle": "^2.0",
        "rollerworks/password-strength-validator": "^1.0",
        "sensio/framework-extra-bundle": "^5.2",
        "sentry/sentry-symfony": "^3.5",
        "simplethings/entity-audit-bundle": "^1.0.1",
        "sllh/iso-codes-validator": "^4.0",
        "snc/redis-bundle": "^3.2.2",
        "sonata-project/admin-bundle": "^3.3",
        "sonata-project/block-bundle": "^3.12",
        "sonata-project/core-bundle": "^3.9",
        "sonata-project/doctrine-extensions": "^1.0",
        "sonata-project/doctrine-orm-admin-bundle": "^3.0.3",
        "sonata-project/exporter": "^1.9",
        "sonata-project/intl-bundle": "^2.2",
        "stof/doctrine-extensions-bundle": "^1.1",
        "swiftmailer/swiftmailer": "^6.0",
        "symfony/config": "^4.2",
        "symfony/console": "^4.3",
        "symfony/contracts": "^1.0",
        "symfony/dependency-injection": "^4.1, !=4.1.2, !=4.2.2",
        "symfony/doctrine-bridge": "^4.1",
        "symfony/dotenv": "^4.2",
        "symfony/event-dispatcher": "^4.1",
        "symfony/expression-language": "^4.1",
        "symfony/filesystem": "^4.1",
        "symfony/flex": "^1.0",
        "symfony/form": "^4.2",
        "symfony/framework-bundle": "^4.2",
        "symfony/http-foundation": "^4.4",
        "symfony/http-kernel": "^4.4",
        "symfony/intl": "^4.1",
        "symfony/lock": "^4.1",
        "symfony/monolog-bundle": "^3.0",
        "symfony/options-resolver": "^4.1",
        "symfony/process": "^4.1",
        "symfony/property-access": "^4.1",
        "symfony/property-info": "^4.1",
        "symfony/proxy-manager-bridge": "^4.1",
        "symfony/psr-http-message-bridge": "^1.0",
        "symfony/routing": "^4.1",
        "symfony/security": "^4.1, !=4.2.1",
        "symfony/security-bundle": "^4.1",
        "symfony/serializer": "^4.2",
        "symfony/swiftmailer-bundle": "^3.2",
        "symfony/templating": "^4.1",
        "symfony/translation": "^4.2",
        "symfony/twig-bridge": "^4.1",
        "symfony/twig-bundle": "^4.1",
        "symfony/validator": "^4.1",
        "symfony/web-link": "^4.2",
        "symfony/webpack-encore-bundle": "^1.0, !=1.1.0",
        "symfony/yaml": "^4.1",
        "thecodingmachine/gotenberg-php-client": "^6.1",
        "theofidry/alice-data-fixtures": "^1.0",
        "twig/extensions": "^1.0",
        "twig/twig": "^2.4",
        "webmozart/assert": "^1.2"
    },
    "require-dev": {
        "dama/doctrine-test-bundle": "^5.0",
        "doctrine/doctrine-fixtures-bundle": "^3.0",
        "fzaninotto/faker": "^1.7",
        "jolicode/gif-exception-bundle": "^1.4",
        "liip/functional-test-bundle": "^2.0",
        "php-http/mock-client": "^1.1",
        "roave/security-advisories": "dev-master",
        "sonata-project/easy-extends-bundle": "^2.5",
        "symfony/debug-bundle": "^4.0",
        "symfony/phpunit-bridge": "^4.3.4",
        "symfony/var-dumper": "^4.0",
        "symfony/web-profiler-bundle": "^4.0"
    },
    "conflict": {
        "api-platform/core": "2.5.4 - 2.5.5",
        "fzaninotto/faker": "<=1.5.0",
        "hautelook/alice-bundle": "2.1.0 - 2.2.0",
        "knplabs/knp-markdown-bundle": "1.5.0",
        "knplabs/knp-menu": "<=2.0.1",
        "liip/functional-test-bundle": ">=2.0.0-alpha4,<=2.0.0-alpha17",
        "sonata-project/doctrine-orm-admin-bundle": "3.6.0 - 3.9.0",
        "symfony/symfony": "*",
        "symfony/property-access": "4.1.9 || 4.2.0 - 4.2.1",
        "symfony/validator": "4.3.0",
        "theofidry/alice-data-fixtures": "1.1.0 - 1.1.2"
    },
    "scripts": {
        "init-scripts": [
            "./composer-scripts",
            "AppBundle\\Composer\\ScriptHandler::prepareParameters",
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters"
        ],
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd",
            "fos:js-routing:dump --target %PUBLIC_DIR%/routing.js": "symfony-cmd"
        },
        "post-install-cmd": [
            "@init-scripts",
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@init-scripts",
            "@auto-scripts"
        ]
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true,
        "vendor-dir": "vendor/php",
        "bin-dir": "vendor/bin"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "extra": {
        "symfony": {
            "allow-contrib": true
        },
        "incenteev-parameters": {
            "file": "config/parameters.yaml",
            "dist-file": "config/parameters-dist.yaml"
        }
    }
}

Yes I know. Quite a lot of dependencies.

I don’t think we should add this to the docs, the problem doesn’t clearly belongs to this bundle and should be solved upstream. In fact, if you don’t have the FrameworkExtraBundle bundle installed everything would be fine

Even if it’s not related to this bundle, It’s about helping the users to upgrade. I took 1 hour to solve this issue. One hour which could be saved with two lines in the Upgrade doc. Do you like your users and wants to help them or not ? šŸ˜‰

So, I don’t know what we could report there… I’m open to a PR to evaluate on a proper text.

Maybe just an extra note? The PSR-7 bit seems to be going away in a forthcoming 6.0 release, but until that’s released this is just an extra thing folks have to keep in mind.

ā€œIf you have SensioFrameworkExtraBundle < 6.0 installed and are not using its PSR-7 feature, you will need to disable it in your application’s configuration or there will most likely be a crash due to missing dependencies, you can fix this by adding this to the bundle’s configuration:ā€ (then the snippet posted in https://github.com/getsentry/sentry-symfony/issues/379#issuecomment-768184584 goes here).

TBH, the error itself isn’t all that bad and I don’t think anyone’s intent is to play the blame game on who’s wrong; I actually am more surprised the Sensio bundle had that feature enabled by default than the fact I got an error related to that after upgrading the Sentry bundle.

@ste93cry Thanks.

In case somebody else stumbles upon this issue the situation is described here and a workaround is provided as well.

Looking at the stacktrace, the issue is related to the SensioFrameworkExtraBundle bundle

https://github.com/sensiolabs/SensioFrameworkExtraBundle/pull/710

For me, the solution was just to delete psr_http_message_bridge.yaml, which some stupid flex recipe thing had produced for no good reason, breaking my application referencing non-existent services.