getsentry / sentry-symfony

The official Symfony SDK for Sentry (sentry.io)
https://sentry.io
MIT License
697 stars 171 forks source link

`Cannot instantiate abstract class Zend\Diactoros\ServerRequestFactory` in a hybrid application on v4 #498

Closed alex-pravdin-sn closed 3 years ago

alex-pravdin-sn commented 3 years ago

Environment

Symfony-sentry version 4.1.1 PHP 8 Symfony 4 + Zend 2-3 (an application in the migration process)

Steps to Reproduce

After the migration to v4, I started getting the following exception during my application startup:

Cannot instantiate abstract class Zend\Diactoros\ServerRequestFactory

While this class exists, it is never used. Some old business logic still use Zend but the application is Symfony-first. That mean Symfony app is loaded always and then some Zend stuff may be executed if needed.

I didn't have this exception on the v3. How to fix it?

Jean85 commented 3 years ago

Can you give us a stack trace of this issue? Can you post your composer.json?

The only place where we would use such a class is in the RequestFetcher, which in turn uses a HttpMessageFactoryInterface, which could be erroneously involved with the Zend class... Maybe it depends on HTTPlug?

alex-pravdin-sn commented 3 years ago

Stack trace:

Error : Cannot instantiate abstract class Zend\Diactoros\ServerRequestFactory
 /var/www/html/app/vendor/php-http/discovery/src/ClassDiscovery.php:213
 /var/www/html/app/vendor/php-http/discovery/src/Psr17FactoryDiscovery.php:74
 /var/www/html/app/vendor/sentry/sentry-symfony/src/Integration/RequestFetcher.php:41
 /var/www/html/app/var/cache/test-cli-debug-xdebug/ContainerDnUB9H2/AppSpringerNature_Index_Worker_App_ZendBridgeAppKernelTestDebugContainer.php:738
 /var/www/html/app/var/cache/test-cli-debug-xdebug/ContainerDnUB9H2/AppSpringerNature_Index_Worker_App_ZendBridgeAppKernelTestDebugContainer.php:696
 /var/www/html/app/var/cache/test-cli-debug-xdebug/ContainerDnUB9H2/AppSpringerNature_Index_Worker_App_ZendBridgeAppKernelTestDebugContainer.php:448
 /var/www/html/app/vendor/symfony/event-dispatcher/EventDispatcher.php:301
 /var/www/html/app/vendor/symfony/event-dispatcher/EventDispatcher.php:264
 /var/www/html/app/vendor/symfony/event-dispatcher/EventDispatcher.php:239
 /var/www/html/app/vendor/symfony/event-dispatcher/EventDispatcher.php:73
 /var/www/html/app/vendor/symfony/http-kernel/HttpKernel.php:134
 /var/www/html/app/vendor/symfony/http-kernel/HttpKernel.php:80
 /var/www/html/app/vendor/symfony/http-kernel/Kernel.php:201
 /var/www/html/app/tests/Integration/HandlerTest.php:32

composer.json:

{
    "require": {
        "php": ">=8.0",
        "ext-mongo": "1.5",
        "ext-json": "*",
        "ext-simplexml": "*",
        "ext-mbstring": "*",
        "ext-bcmath": "*",
        "ext-curl": "*",

        "nesbot/carbon": "^2",

        "symfony/http-kernel": "^4.4 || ^5.1",
        "symfony/framework-bundle": "^4.4 || ^5.1",
        "symfony/event-dispatcher": "^4.4 || ^5.1",
        "symfony/console": "^4.4 || ^5.1",
        "symfony/filesystem": "^5.1",
        "symfony/process": "^5.1",
        "symfony/dependency-injection": "^4.4 || ^5.1",
        "symfony/config": "^4.4 || ^5.1",
        "symfony/expression-language": "^5.1",
        "symfony/yaml": "^5.1",
        "symfony/proxy-manager-bridge": "^4.4 || ^5.1",
        "symfony/monolog-bundle": "^3.6",

        "sentry/sentry-symfony": "^4.0.0",

        "aws/aws-sdk-php": "*",
        "google/cloud-core": "^1.38",
        "google/cloud-bigquery": "^1.16",

        "alcaeus/mongo-php-adapter": "*",
        "mongodb/mongodb": "1.5",
        "doctrine/mongodb-odm-bundle": "^3.6"
    },
    "require-dev": {
        "phpunit/phpunit": "^8.5.8",
        "phpspec/phpspec": "^7.0.1",
        "symfony/dotenv": "^5.1"
    }
}

There are many internal packages in the composer.json file that I removed from here. They pull Zend packages. The composer info command prints the following list of installed packages:

alcaeus/mongo-php-adapter                      1.2.0     Adapter to provide ext-mongo interface on top of mongo-php-library
aws/aws-sdk-php                                3.180.6   AWS SDK for PHP - Use Amazon Web Services in your PHP project
brick/math                                     0.9.2     Arbitrary-precision arithmetic library
clue/stream-filter                             v1.5.0    A simple and modern approach to stream filtering in PHP
composer/package-versions-deprecated           1.11.99.1 Composer plugin that provides efficient querying for installed package versions (no runtime IO)
container-interop/container-interop            1.2.0     Promoting the interoperability of container objects (DIC, SL, etc.)
dataground/simpledom                           1.0.9     A bridge between SimpleXML and the DOM extension, plus a bunch of convenience methods
doctrine/annotations                           1.12.1    Docblock Annotations Parser
doctrine/cache                                 1.11.0    PHP Doctrine Cache library is a popular cache implementation that supports many different drivers such as redis, memcache, apc, mongod...
doctrine/collections                           1.6.7     PHP Doctrine Collections library that adds additional functionality on top of PHP arrays.
doctrine/common                                2.13.3    PHP Doctrine Common project is a library that provides additional functionality that other Doctrine projects depend on such as better ...
doctrine/event-manager                         1.1.1     The Doctrine Event Manager is a simple PHP event system that was built to be used with the various Doctrine projects.
doctrine/inflector                             1.4.4     PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural for...
doctrine/instantiator                          1.4.0     A small, lightweight utility to instantiate objects in PHP without invoking their constructors
doctrine/lexer                                 1.2.1     PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.
doctrine/mongodb                               1.6.4     Doctrine MongoDB Abstraction Layer
doctrine/mongodb-odm                           1.3.7     Doctrine MongoDB Object Document Mapper
doctrine/mongodb-odm-bundle                    3.6.2     Symfony2 Doctrine MongoDB Bundle
doctrine/persistence                           1.3.8     The Doctrine Persistence project is a set of shared interfaces and functionality that the different Doctrine object mappers share.
doctrine/reflection                            1.2.2     The Doctrine Reflection project is a simple library used by the various Doctrine projects which adds some additional functionality on ...
elasticsearch/elasticsearch                    v7.12.0   PHP Client for Elasticsearch
ezimuel/guzzlestreams                          3.0.1     Fork of guzzle/streams (abandoned) to be used with elasticsearch-php
ezimuel/ringphp                                1.1.2     Fork of guzzle/RingPHP (abandoned) to be used with elasticsearch-php
firebase/php-jwt                               v5.2.1    A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.
friendsofphp/proxy-manager-lts                 v1.0.3    Adding support for a wider range of PHP versions to ocramius/proxy-manager
google/auth                                    v1.15.1   Google Auth Library for PHP
google/cloud-bigquery                          v1.22.0   BigQuery Client for PHP
google/cloud-core                              v1.42.0   Google Cloud PHP shared dependency, providing functionality useful to all components.
google/cloud-tasks                             v1.9.1    Google Cloud Tasks Client for PHP
google/common-protos                           1.3       Google API Common Protos for PHP
google/gax                                     v1.7.1    Google API Core for PHP
google/grpc-gcp                                0.1.5     gRPC GCP library for channel management
google/protobuf                                v3.16.0   proto library for PHP
grpc/grpc                                      1.36.0    gRPC library for PHP
guzzlehttp/guzzle                              7.3.0     Guzzle is a PHP HTTP client library
guzzlehttp/promises                            1.4.1     Guzzle promises library
guzzlehttp/psr7                                1.8.2     PSR-7 message implementation that also provides common utility methods
http-interop/http-factory-guzzle               1.0.0     An HTTP Factory using Guzzle PSR7
http-interop/http-middleware                   0.2.0     Common interface for HTTP middleware
jean85/pretty-package-versions                 2.0.3     A library to get pretty versions strings of installed dependencies
laminas/laminas-code                           3.4.1     Extensions to the PHP Reflection API, static code scanning, and code generation
laminas/laminas-eventmanager                   3.3.1     Trigger and listen to events within a PHP application
laminas/laminas-zendframework-bridge           1.2.0     Alias legacy ZF class names to Laminas Project equivalents.
mongodb/mongodb                                1.5.0     MongoDB driver library
monolog/monolog                                2.2.0     Sends your logs to files, sockets, inboxes, databases and various web services
mtdowling/jmespath.php                         2.6.0     Declaratively specify how to extract elements from a JSON document
myclabs/deep-copy                              1.10.2    Create deep copies (clones) of your objects
nesbot/carbon                                  2.47.0    An API extension for DateTime that supports 281 different languages.
nyholm/dsn                                     2.0.0     Parse your DSN strings in a powerful and flexible way
paragonie/random_compat                        v9.99.99  PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
phar-io/manifest                               2.0.1     Component for reading phar.io manifest information from a PHP Archive (PHAR)
phar-io/version                                3.1.0     Library for handling version information and constraints
php-http/client-common                         2.3.0     Common HTTP Client implementations and tools for HTTPlug
php-http/discovery                             1.13.0    Finds installed HTTPlug implementations and PSR-7 message factories
php-http/httplug                               2.2.0     HTTPlug, the HTTP client abstraction for PHP
php-http/message                               1.11.0    HTTP Message related tools
php-http/message-factory                       v1.0.2    Factory interfaces for PSR-7 HTTP Message
php-http/promise                               1.1.0     Promise used for asynchronous HTTP requests
phpdocumentor/reflection-common                2.2.0     Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock              5.2.2     With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in...
phpdocumentor/type-resolver                    1.4.0     A PSR-5 based resolver of Class names, Types and Structural Element Names
phpspec/php-diff                               v1.1.3    A comprehensive library for generating differences between two hashable objects (strings or arrays).
phpspec/phpspec                                7.0.1     Specification-oriented BDD framework for PHP 7.1+
phpspec/prophecy                               1.13.0    Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage                      7.0.14    Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator                      2.0.3     FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-text-template                      1.2.1     Simple template engine.
phpunit/php-timer                              2.1.3     Utility class for timing
phpunit/php-token-stream                       4.0.4     Wrapper around PHP's tokenizer extension.
phpunit/phpunit                                8.5.15    The PHP Unit Testing framework.
psr/cache                                      1.0.1     Common interface for caching libraries
psr/container                                  1.1.1     Common Container Interface (PHP FIG PSR-11)
psr/http-client                                1.0.1     Common interface for HTTP clients
psr/http-factory                               1.0.1     Common interfaces for PSR-7 HTTP message factories
psr/http-message                               1.0.1     Common interface for HTTP messages
psr/log                                        1.1.4     Common interface for logging libraries
psr/simple-cache                               1.0.1     Common interfaces for simple caching
ralouphie/getallheaders                        3.0.3     A polyfill for getallheaders.
ramsey/collection                              1.1.3     A PHP 7.2+ library for representing and manipulating collections.
ramsey/uuid                                    4.1.1     A PHP library for generating and working with universally unique identifiers (UUIDs).
react/promise                                  v2.8.0    A lightweight implementation of CommonJS Promises/A for PHP
rize/uri-template                              0.3.3     PHP URI Template (RFC 6570) supports both expansion & extraction
ruflin/elastica                                7.1.1     Elasticsearch Client
sebastian/code-unit-reverse-lookup             1.0.2     Looks up which function or method a line of code belongs to
sebastian/comparator                           3.0.3     Provides the functionality to compare PHP values for equality
sebastian/diff                                 3.0.3     Diff implementation
sebastian/environment                          4.2.4     Provides functionality to handle HHVM/PHP environments
sebastian/exporter                             3.1.3     Provides the functionality to export PHP variables for visualization
sebastian/global-state                         3.0.1     Snapshotting of global state
sebastian/object-enumerator                    3.0.4     Traverses array structures and object graphs to enumerate all referenced objects
sebastian/object-reflector                     1.1.2     Allows reflection of object attributes, including inherited and non-public ones
sebastian/recursion-context                    3.0.1     Provides functionality to recursively process PHP variables
sebastian/resource-operations                  2.0.2     Provides a list of PHP built-in functions that operate on resources
sebastian/type                                 1.1.4     Collection of value objects that represent the types of the PHP type system
sebastian/version                              2.0.1     Library that helps with managing the version number of Git-hosted PHP projects
sentry/sdk                                     3.1.0     This is a metapackage shipping sentry/sentry with a recommended HTTP client.
sentry/sentry                                  3.2.2     A PHP SDK for Sentry (http://sentry.io)
sentry/sentry-symfony                          4.1.1     Symfony integration for Sentry (http://getsentry.com)
symfony/cache                                  v5.2.7    Provides an extended PSR-6, PSR-16 (and tags) implementation
symfony/cache-contracts                        v2.4.0    Generic abstractions related to caching
symfony/config                                 v4.4.22   Helps you find, load, combine, autofill and validate configuration values of any kind
symfony/console                                v4.4.22   Eases the creation of beautiful and testable command line interfaces
symfony/debug                                  v4.4.22   Provides tools to ease debugging PHP code
symfony/dependency-injection                   v4.4.22   Allows you to standardize and centralize the way objects are constructed in your application
symfony/deprecation-contracts                  v2.4.0    A generic function and convention to trigger deprecation notices
symfony/doctrine-bridge                        v4.4.22   Provides integration for Doctrine with various Symfony components
symfony/dotenv                                 v5.2.4    Registers environment variables from a .env file
symfony/error-handler                          v4.4.22   Provides tools to manage errors and ease debugging PHP code
symfony/event-dispatcher                       v4.4.20   Provides tools that allow your application components to communicate with each other by dispatching events and listening to them
symfony/event-dispatcher-contracts             v1.1.9    Generic abstractions related to dispatching event
symfony/expression-language                    v5.2.7    Provides an engine that can compile and evaluate expressions
symfony/filesystem                             v5.2.7    Provides basic utilities for the filesystem
symfony/finder                                 v5.2.4    Finds files and directories via an intuitive fluent interface
symfony/framework-bundle                       v4.4.22   Provides a tight integration between Symfony components and the Symfony full-stack framework
symfony/http-client                            v5.2.7    Provides powerful methods to fetch HTTP resources synchronously or asynchronously
symfony/http-client-contracts                  v2.4.0    Generic abstractions related to HTTP clients
symfony/http-foundation                        v5.2.7    Defines an object-oriented layer for the HTTP specification
symfony/http-kernel                            v4.4.22   Provides a structured process for converting a Request into a Response
symfony/monolog-bridge                         v5.2.7    Provides integration for Monolog with various Symfony components
symfony/monolog-bundle                         v3.7.0    Symfony MonologBundle
symfony/options-resolver                       v4.4.20   Provides an improved replacement for the array_replace PHP function
symfony/polyfill-ctype                         v1.22.1   Symfony polyfill for ctype functions
symfony/polyfill-mbstring                      v1.22.1   Symfony polyfill for the Mbstring extension
symfony/polyfill-php73                         v1.22.1   Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-php80                         v1.22.1   Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/polyfill-uuid                          v1.22.1   Symfony polyfill for uuid functions
symfony/process                                v5.2.7    Executes commands in sub-processes
symfony/proxy-manager-bridge                   v4.4.20   Provides integration for ProxyManager with various Symfony components
symfony/psr-http-message-bridge                v2.1.0    PSR HTTP message bridge
symfony/routing                                v4.4.22   Maps an HTTP request to a set of configuration variables
symfony/security-core                          v5.2.7    Symfony Security Component - Core Library
symfony/service-contracts                      v2.4.0    Generic abstractions related to writing services
symfony/translation                            v4.4.21   Provides tools to internationalize your application
symfony/translation-contracts                  v2.4.0    Generic abstractions related to translation
symfony/var-dumper                             v5.2.7    Provides mechanisms for walking through any arbitrary PHP variable
symfony/var-exporter                           v5.2.7    Allows exporting any serializable PHP data structure to plain PHP code
symfony/yaml                                   v5.2.7    Loads and dumps YAML files
theseer/tokenizer                              1.2.0     A small library for converting tokenized PHP source code into XML and potentially other formats
true/punycode                                  v2.1.1    A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA)
webmozart/assert                               1.10.0    Assertions to validate method input/output with nice error messages.
zendframework/zend-authentication              2.7.0     provides an API for authentication and includes concrete authentication adapters for common use case scenarios
zendframework/zend-barcode                     2.8.0     Programmatically create and render barcodes as images or in PDFs
zendframework/zend-cache                       2.9.0     Caching implementation with a variety of storage options, as well as codified caching strategies for callbacks, classes, and output
zendframework/zend-captcha                     2.9.0     Generate and validate CAPTCHAs using Figlets, images, ReCaptcha, and more
zendframework/zend-config                      2.6.0     provides a nested object property based user interface for accessing this configuration data within application code
zendframework/zend-console                     2.8.0     Build console applications using getopt syntax or routing, complete with prompts
zendframework/zend-crypt                       3.3.1     Strong cryptography tools and password hashing
zendframework/zend-db                          2.11.0    Database abstraction layer, SQL abstraction, result set abstraction, and RowDataGateway and TableDataGateway implementations
zendframework/zend-debug                       2.6.0     Safely dump debug information to HTML
zendframework/zend-di                          2.6.1
zendframework/zend-diactoros                   1.8.7     PSR HTTP Message implementations
zendframework/zend-dom                         2.7.2     provides tools for working with DOM documents and structures
zendframework/zend-escaper                     2.6.1     Securely and safely escape HTML, HTML attributes, JavaScript, CSS, and URLs
zendframework/zend-feed                        2.12.0    provides functionality for consuming RSS and Atom feeds
zendframework/zend-file                        2.8.3     Locate PHP classfiles
zendframework/zend-filter                      2.9.2     Programmatically filter and normalize data and files
zendframework/zend-form                        2.14.3    Validate and display simple and complex forms, casting forms to business objects and vice versa
zendframework/zend-http                        2.11.2    Provides an easy interface for performing Hyper-Text Transfer Protocol (HTTP) requests
zendframework/zend-hydrator                    2.4.2     Serialize objects to arrays, and vice versa
zendframework/zend-i18n                        2.10.1    Provide translations for your application, and filter and validate internationalized values
zendframework/zend-i18n-resources              2.6.1     Provides validator translations for zend-i18n's Translator
zendframework/zend-inputfilter                 2.10.1    Normalize and validate input sets from the web, APIs, the CLI, and more, including files
zendframework/zend-json                        3.1.2     provides convenience methods for serializing native PHP to JSON and decoding JSON to native PHP
zendframework/zend-json-server                 3.2.0     Zend Json-Server is a JSON-RPC server implementation.
zendframework/zend-loader                      2.6.1     Autoloading and plugin loading strategies
zendframework/zend-log                         2.12.0    Robust, composite logger with filtering, formatting, and PSR-3 support
zendframework/zend-mail                        2.10.0    Provides generalized functionality to compose and send both text and MIME-compliant multipart e-mail messages
zendframework/zend-math                        3.2.0     Create cryptographically secure pseudo-random numbers, and manage big integers
zendframework/zend-memory                      2.6.1     Manage data in an environment with limited memory
zendframework/zend-mime                        2.7.2     Create and parse MIME messages and parts
zendframework/zend-modulemanager               2.8.4     Modular application system for zend-mvc applications
zendframework/zend-mvc                         3.1.1     Zend Framework's event-driven MVC layer, including MVC Applications, Controllers, and Plugins
zendframework/zend-mvc-console                 1.2.0     Integration between zend-mvc and zend-console
zendframework/zend-mvc-form                    1.0.0     Metapackage with all requirements needed to use zend-form with zend-mvc.
zendframework/zend-mvc-i18n                    1.1.1     Integration between zend-mvc and zend-i18n
zendframework/zend-mvc-plugin-fileprg          1.1.0     Post/Redirect/Get plugin with file upload handling for zend-mvc controllers
zendframework/zend-mvc-plugin-flashmessenger   1.2.0     Plugin for creating and exposing flash messages via zend-mvc controllers
zendframework/zend-mvc-plugin-identity         1.1.1     Plugin for retrieving the current authenticated identity within zend-mvc controllers
zendframework/zend-mvc-plugin-prg              1.2.0     Post/Redirect/Get plugin for zend-mvc controllers
zendframework/zend-mvc-plugins                 1.0.1     Collection of all stable zend-mvc plugins served via separate packages.
zendframework/zend-navigation                  2.9.1     Manage trees of pointers to web pages in order to build navigation systems
zendframework/zend-paginator                   2.8.2     Paginate collections of data from arbitrary sources
zendframework/zend-permissions-acl             2.7.1     Provides a lightweight and flexible access control list (ACL) implementation for privileges management
zendframework/zend-permissions-rbac            2.6.0     provides a role-based access control management
zendframework/zend-progressbar                 2.7.0     Create and update progress bars in different environments
zendframework/zend-psr7bridge                  0.2.2     PSR-7 <-> Zend\Http bridge
zendframework/zend-router                      3.3.0     Flexible routing system for HTTP and console applications
zendframework/zend-serializer                  2.9.1     Serialize and deserialize PHP structures to a variety of representations
zendframework/zend-server                      2.8.1     Create Reflection-based RPC servers
zendframework/zend-servicemanager              3.4.0     Factory-Driven Dependency Injection Container
zendframework/zend-servicemanager-di           1.2.1     zend-di integration for zend-servicemanager
zendframework/zend-session                     2.9.1     Object-oriented interface to PHP sessions and storage
zendframework/zend-soap                        2.8.0
zendframework/zend-stdlib                      3.2.1     SPL extensions, array utilities, error handlers, and more
zendframework/zend-stratigility                1.3.3     Middleware for PHP
zendframework/zend-tag                         2.7.1     Manipulate and weight taggable items, and create tag clouds
zendframework/zend-test                        3.3.0     Tools to facilitate unit testing of zend-mvc applications
zendframework/zend-text                        2.7.1     Create FIGlets and text-based tables
zendframework/zend-uri                         2.7.1     A component that aids in manipulating and validating » Uniform Resource Identifiers (URIs)
zendframework/zend-validator                   2.13.0    Validation classes for a wide range of domains, and the ability to chain validators to create complex validation criteria
zendframework/zend-view                        2.11.4    Flexible view layer supporting and providing multiple view layers, helpers, and more
zendframework/zend-xml2json                    3.1.2     Provides functionality for converting XML to JSON, optionally including XML attributes
zendframework/zend-xmlrpc                      2.9.0     Fully-featured XML-RPC server and client implementations
zendframework/zendframework                    3.0.0     Zend Framework
zendframework/zendxml                          1.2.0     Utility library for XML usage, best practices, and security in PHP

The Zend part is only initialized when a service with Zend dependencies is requested through the Symfony container.

alex-pravdin-sn commented 3 years ago

The only workaround I have invented is to define the following services explicitly:

  Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory:
  Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface: '@Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory'

  Http\Factory\Guzzle\ServerRequestFactory:
  Psr\Http\Message\ServerRequestFactoryInterface: '@Http\Factory\Guzzle\ServerRequestFactory'

  Http\Factory\Guzzle\UploadedFileFactory:
  Psr\Http\Message\UploadedFileFactoryInterface: '@Http\Factory\Guzzle\UploadedFileFactory'

  Http\Factory\Guzzle\ResponseFactory:
  Psr\Http\Message\ResponseFactoryInterface: '@Http\Factory\Guzzle\ResponseFactory'

  Http\Factory\Guzzle\StreamFactory:
  Psr\Http\Message\StreamFactoryInterface: '@Http\Factory\Guzzle\StreamFactory'

But I guess it will be more convenient to be able to disable Zend-related candidates in factories' discovery logic. Something like Psr17FactoryDiscovery::disableZendFactories() that can be called before the application initialization. As of now, factories' class names are hardcoded privately and users can not change them. I think that any kind of customization without services' definitions would be nice.

Jean85 commented 3 years ago

The issue is rising from a downstream dependency, php-http/discovery, which is part of HTTPlug. If you have any further issues, you should report those to them.

To be more precise, the code that decides which strategy to apply for discovery it's here: https://github.com/php-http/discovery/blob/master/src/Strategy/CommonClassesStrategy.php#L55-L59

As you can see, Diactoros is the third choice there, so as a first workaround you can simply install one of the two previous choices to avoid the issue.

Another possible workaround is installing the Symfony PSR-7 bridge, which would be picked up automatically by the Sentry Bundle in the service definition: https://github.com/getsentry/sentry-symfony/blob/9e101adee6bc4a934bef1c7d68c7788060fc3b37/src/Resources/config/services.xml#L117

Normally that was bundled with the FrameworkExtraBundle, but since 6.0 that's no longer the case, so it would be better to install the bridge on its own, see https://github.com/symfony/psr-http-message-bridge/pull/89 and https://github.com/symfony/recipes/pull/899.

alex-pravdin-sn commented 3 years ago

Thank you for the answer.

The only issue is that the Symfony PSR-7 Bridge service is not pulled automatically by the Sentry service. Because this package is not a bundle and nothing is registered automatically when I add it. I have to register services from the Symfony package manually, particularly a Symfony\Bridge\PsrHttpMessage\HttpMessageFactoryInterface implementation. Is it possible to add an automatic detection of the Symfony PSR-7 Bridge package presence and its automatic configuration to avoid manual operations?

Jean85 commented 3 years ago

As I already reported, that is done in the recipe: https://github.com/symfony/recipes/pull/899/files

alex-pravdin-sn commented 3 years ago

Could you refer to this recipe in the package readme? We're not using Symfony Flex, because our application is pretty old and we're migrating slowly, without adding the Flex "magic".

iker-barriocanal commented 3 years ago

This issue looks like a question that has already been answered, so closing it. Feel free to comment here if you have further questions.

Thanks!