-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot instantiate abstract class Zend\Diactoros\ServerRequestFactory
in a hybrid application on v4
#498
Comments
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 |
Stack trace:
There are many internal packages in the
The Zend part is only initialized when a service with Zend dependencies is requested through the Symfony container. |
The only workaround I have invented is to define the following services explicitly:
But I guess it will be more convenient to be able to disable Zend-related candidates in factories' discovery logic. Something like |
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:
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 symfony/psr-http-message-bridge#89 and symfony/recipes#899. |
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 |
As I already reported, that is done in the recipe: https://github.com/symfony/recipes/pull/899/files |
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". |
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! |
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:
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?
The text was updated successfully, but these errors were encountered: