getsentry / sentry-laravel

The official Laravel SDK for Sentry (sentry.io)
https://sentry.io
MIT License
1.24k stars 189 forks source link

Class 'Symfony\\Bridge\\PsrHttpMessage\\Factory\\DiactorosFactory' not found #473

Closed marcinincreo closed 1 year ago

marcinincreo commented 3 years ago

Hi,

After updating sentry-laravel from 2.3.1 to 2.4 exception capture stops working. That's connected to using symfony/psr-http-message-bridge v2 (v1 does not throw error).

stayallive commented 3 years ago

Can you please share your composer.json so we can try to reproduce?

marcinincreo commented 3 years ago

@stayallive

hope this helps:

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": "^7.2",
        "ext-curl": "*",
        "ext-json": "*",
        "ext-zip": "*",
        "bacon/bacon-qr-code": "^2.0",
        "barryvdh/laravel-cors": "^0.11.3",
        "barryvdh/laravel-dompdf": "^0.8.3",
        "daltcore/lara-pdf-merger": "^2.0",
        "doctrine/dbal": "^2.9",
        "fideloper/proxy": "^4.0",
        "firebase/php-jwt": "^5.0",
        "guzzlehttp/guzzle": "^6.3",
        "intervention/image": "^2.5",
        "laravel-lang/lang": "~3.0",
        "laravel/framework": "5.7.29",
        "laravel/tinker": "^v1.0.10",
        "maatwebsite/excel": "^3.1.22",
        "nesbot/carbon": "1.33",
        "sentry/sentry-laravel": "^2.4",
        "silber/bouncer": "v1.0.0-rc.4",
        "spatie/laravel-newsletter": "^4.2",
        "symfony/psr-http-message-bridge": "1.3.0",
        "tymon/jwt-auth": "1.0.*"
    },
    "require-dev": {
        "barryvdh/laravel-ide-helper": "^2.6",
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7"
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/"
        },
        "files": [
            "app/Helpers/helpers.php"
        ]
    },
    "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 --ansi"
        ],
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ]
    },
    "config": {
        "preferred-install": "dist",
        "sort-packages": true,
        "optimize-autoloader": true,
        "platform": {
            "php": "7.2"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}
stayallive commented 3 years ago

Hey sorry for the delay, just to confirm this lists symfony/psr-http-message-bridge: 1.3.0 but you said the issue was with v2 right?

I have tried "symfony/psr-http-message-bridge": "^2", and composer update but cannot reproduce the error like that :( Have you ran a composer update in your project too?

marcinincreo commented 3 years ago

I tried that now with fresh Laravel 5.7 installation since I was thinking some other modules break it, but I got same error. Composer file to try it out:

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0",
        "sentry/sentry-laravel": "^2.5"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^2.0",
        "phpunit/phpunit": "^7.0"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

I tried that out also with Laravel 8 but everything works there as expected.

marcinincreo commented 3 years ago

Some additional information:

harpster604 commented 3 years ago

We are facing the exact same issue with Laravel 5.7

stayallive commented 3 years ago

I think I found the issue all, this was an oversight on my part.

Laravel 5.x uses another package to generate the PSR-7 request objects and that was what was throwing the error.

Can you all test it by changing this in your composer.json (and running composer update) and let me know if that indeed also solved the error for you?

-   "sentry/sentry-laravel": "^2.4",
+   "sentry/sentry-laravel": "dev-master#96b3cf2ac4d71af39497e23098522d7e695aaf95"
evileyecc1 commented 3 years ago

I think I found the issue all, this was an oversight on my part.

Laravel 5.x uses another package to generate the PSR-7 request objects and that was what was throwing the error.

Can you all test it by changing this in your composer.json (and running composer update) and let me know if that indeed also solved the error for you?

-   "sentry/sentry-laravel": "^2.4",
+   "sentry/sentry-laravel": "dev-master#96b3cf2ac4d71af39497e23098522d7e695aaf95"

I use Lararvel 6.x and sentry 2.5.Same problem.The dev package version reslove this problem

stayallive commented 3 years ago

Laravel 6.x uses nyholm/psr7: https://laravel.com/docs/6.x/requests#psr7-requests

We require this PSR-7 package for you:

https://github.com/getsentry/sentry-laravel/blob/96b3cf2ac4d71af39497e23098522d7e695aaf95/composer.json#L29

So you are either on a very old Laravel 6 (6.9 or below) or there is something else going on.

Can you confirm your Laravel version?

evileyecc1 commented 3 years ago

I will check it tmmr.cause code in corp lan network

发自我的iPhone

------------------ Original ------------------ From: Alex Bouma @.> Date: Mon,May 10,2021 6:54 PM To: getsentry/sentry-laravel @.> Cc: JiaYing Chen @.>, Comment @.> Subject: Re: [getsentry/sentry-laravel] Class 'Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory' not found (#473)

marcinincreo commented 3 years ago

@stayallive solution worked for 5.7 and fixed the issue

stayallive commented 3 years ago

2.5.3 was just released resolving this 👍

cdkth commented 2 years ago

I'm facing this issue on the latest version 2.13.0. I'm using Laravel version 5.8. It works without any error on the previous version 2.12.1. Running on Ubuntu 20.04 with PHP v7.3.33

rizaldywirawan commented 2 years ago

I'm facing this issue on the latest version 2.13.0. I'm using Laravel version 5.8. It works without any error on the previous version 2.12.1. Running on Ubuntu 20.04 with PHP v7.3.33

I can confirm this issue as well.

spont4e commented 1 year ago

I have the same problem with Laravel 5.7 and Sentry 2.13.0 with PHP 7.4.30.

cleptric commented 1 year ago

I'll take a look!