我目前正在重构一个symfony 6.3应用程序,以删除sensio/framework-extra-bundle
,因为它自symfony 6.2以来已被弃用。
在重构@ParamConverter
注解以使用symfony等效的#[MapEntity]
属性时,我在该路由的功能测试中得到以下错误:
<!-- Unable to guess how to get a Doctrine instance from the request information for parameter "externalAttachment". (500 Internal Server Error) -->
症状类似于Unable to guess how to get a Doctrine instance from the request information,但我想使用#[MapEntity]
属性
以下是我重构的差异:
class CopyExternalAttachmentAction extends AbstractController
{
#[Route(path: '/app/external_attachment/{advertisementId}/{attachmentId}/copy', name: 'external_attachment_copy', requirements: ['advertisementId' => '\d+', 'attachmentId' => '\d+'], options: ['expose' => true], methods: ['GET'])]
- #[Entity('attachment', expr: 'repository.findValidAttachment(advertisementId, attachmentId)')]
- public function __invoke(ExternalAttachment $attachment): Response
+ public function __invoke(
+ #[MapEntity(expr: 'repository.findValidAttachment(advertisementId, attachmentId)')]
+ ExternalAttachment $externalAttachment
+ ): Response
...
当我现在composer remove sensio/framework-extra-bundle
时,错误变为
<!-- You have requested a non-existent resolver "Symfony\Bridge\Doctrine\ArgumentResolver\EntityValueResolver". Did you mean one of these: "Symfony\Component\HttpKernel\Controller\ArgumentResolver\BackedEnumValueResolver", "Symfony\Component\HttpKernel\Controller\ArgumentResolver\DateTimeValueResolver", "Symfony\Component\HttpKernel\Controller\ArgumentResolver\DefaultValueResolver", "Symfony\Component\HttpKernel\Controller\ArgumentResolver\QueryParameterValueResolver", "Symfony\Component\HttpKernel\Controller\ArgumentResolver\RequestAttributeValueResolver", "Symfony\Component\HttpKernel\Controller\ArgumentResolver\RequestPayloadValueResolver", "Symfony\Component\HttpKernel\Controller\ArgumentResolver\RequestValueResolver", "Symfony\Component\HttpKernel\Controller\ArgumentResolver\ServiceValueResolver", "Symfony\Component\HttpKernel\Controller\ArgumentResolver\SessionValueResolver", "Symfony\Component\HttpKernel\Controller\ArgumentResolver\VariadicValueResolver", "Symfony\Component\Security\Http\Controller\SecurityTokenValueResolver", "Symfony\Component\Security\Http\Controller\UserValueResolver", "argument_resolver.not_tagged_controller", "doctrine.orm.entity_value_resolver", "sonata.admin.argument_resolver.admin", "sonata.admin.argument_resolver.proxy_query"? (500 Internal Server Error) -->
这对我来说似乎很奇怪,因为我不再使用ParamConverter了。
我现在的问题是:为什么symfony/doctrine在这种情况下找不到EntityValueResolver
?
更多详情
composer.json:
...
"require": {
"php": "^8.2",
"ext-ctype": "*",
"ext-dom": "*",
"ext-iconv": "*",
"ext-json": "*",
"ext-zip": "*",
"babdev/pagerfanta-bundle": "^4.2",
"doctrine/annotations": "^1.8",
"doctrine/doctrine-bundle": "^2.2",
"doctrine/doctrine-fixtures-bundle": "^3.3",
"doctrine/doctrine-migrations-bundle": "^3.0",
"doctrine/orm": "*",
"dragonmantank/cron-expression": "^3.3",
"enqueue/amqp-lib": "^0.10.19",
"enqueue/enqueue-bundle": "^0.10.8",
"enqueue/job-queue": "^0.10.8",
"fakerphp/faker": "^1.23",
"friendsofsymfony/jsrouting-bundle": "^3.3",
"gedmo/doctrine-extensions": "^3.0",
"geocoder-php/free-geoip-provider": "^4.3",
"geocoder-php/google-maps-provider": "^4.5",
"geocoder-php/nominatim-provider": "^5.4",
"graylog2/gelf-php": "^2.0",
"happyr/doctrine-specification": "^2.0",
"happyr/message-serializer": "^0.5.1",
"igorw/get-in": "~1.0",
"knplabs/knp-snappy-bundle": "^1.7",
"knplabs/knp-time-bundle": "^2.0",
"knpuniversity/oauth2-client-bundle": "^2.11",
"laminas/laminas-soap": "^2.8",
"lcobucci/jwt": "^5.0",
"league/flysystem": "^3.0",
"league/flysystem-aws-s3-v3": "^3.0",
"league/flysystem-bundle": "^3.0",
"league/flysystem-ftp": "^3.0",
"league/flysystem-memory": "^3.0",
"league/flysystem-sftp-v3": "^3.15",
"liip/imagine-bundle": "^2.2",
"liip/monitor-bundle": "^2.16",
"mikey179/vfsstream": "^1.6",
"myclabs/deep-copy": "^1.10",
"myclabs/php-enum": "^1.8",
"nelmio/security-bundle": "^3.0",
"nikic/iter": "^2.0",
"nyholm/psr7": "^1.3",
"ocramius/doctrine-batch-utils": "*",
"pagerfanta/doctrine-orm-adapter": "^4.2",
"pagerfanta/twig": "^4.2",
"php-http/cache-plugin": "^1.7",
"php-http/discovery": "^1.15",
"php-http/httplug-bundle": "^1.18",
"phpoption/phpoption": "^1.7",
"phpseclib/phpseclib": "^3",
"portphp/csv": "^2.0",
"portphp/dbal": "^1.0@dev",
"portphp/doctrine": "^1.1",
"portphp/portphp": "^1.4",
"portphp/steps": "^1.3",
"portphp/symfony-console": "^1.0",
"roave/better-reflection": "^6.12",
"sensio/framework-extra-bundle": "^6.1",
"sonata-project/admin-bundle": "*",
"sonata-project/doctrine-orm-admin-bundle": "*",
"sonata-project/entity-audit-bundle": "1.9.*",
"sroze/messenger-enqueue-transport": "^0.6.0",
"stevenmaguire/oauth2-keycloak": "^4.0",
"stof/doctrine-extensions-bundle": "^1.6",
"sylius-labs/association-hydrator": "^1.1",
"sylius/grid-bundle": "^1.8",
"symfony/amqp-messenger": "*",
"symfony/console": "*",
"symfony/doctrine-messenger": "*",
"symfony/dotenv": "*",
"symfony/expression-language": "6.3.*",
"symfony/flex": "^1.12",
"symfony/framework-bundle": "*",
"symfony/http-client": "*",
"symfony/lock": "*",
"symfony/mailer": "*",
"symfony/messenger": "*",
"symfony/monolog-bundle": "*",
"symfony/polyfill-intl-messageformatter": "*",
"symfony/polyfill-php74": "*",
"symfony/property-info": "*",
"symfony/runtime": "*",
"symfony/security-bundle": "*",
"symfony/twig-bundle": "*",
"symfony/validator": "*",
"symfony/web-link": "*",
"symfony/webpack-encore-bundle": "*",
"symfony/workflow": "*",
"symfony/yaml": "*",
"twig/cssinliner-extra": "^3.0",
"twig/extra-bundle": "^2.12|^3.0",
"twig/inky-extra": "^3.0",
"twig/intl-extra": "^3.2",
"twig/twig": "^2.12|^3.0",
"vich/uploader-bundle": "^2.1",
"webmozart/assert": "^1.9",
"willdurand/geocoder-bundle": "^5.11",
"willdurand/js-translation-bundle": "^5.0"
},
"extra": {
"symfony": {
"allow-contrib": true,
"require": "6.3.*"
}
}
...
composer info
所有以doctrine/
开头的软件包
doctrine/annotations 1.14.3 Docblock Annotations Parser
doctrine/cache 2.2.0 PHP Doctrine Cache library is a popular cache implementation that su...
doctrine/collections 1.8.0 PHP Doctrine Collections library that adds additional functionality ...
doctrine/common 3.4.3 PHP Doctrine Common project is a library that provides additional fu...
doctrine/data-fixtures 1.6.7 Data Fixtures for all Doctrine Object Managers
doctrine/dbal 2.13.9 Powerful PHP database abstraction layer (DBAL) with many features fo...
doctrine/deprecations v0.5.3 A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 lo...
doctrine/doctrine-bundle 2.7.2 Symfony DoctrineBundle
doctrine/doctrine-fixtures-bundle 3.4.4 Symfony DoctrineFixturesBundle
doctrine/doctrine-migrations-bundle 3.2.4 Symfony DoctrineMigrationsBundle
doctrine/event-manager 1.2.0 The Doctrine Event Manager is a simple PHP event system that was bui...
doctrine/inflector 2.0.8 PHP Doctrine Inflector is a small library that can perform string ma...
doctrine/instantiator 1.5.0 A small, lightweight utility to instantiate objects in PHP without i...
doctrine/lexer 1.2.3 PHP Doctrine Lexer parser library that can be used in Top-Down, Recu...
doctrine/migrations 3.4.2 PHP Doctrine Migrations project offer additional functionality on to...
doctrine/orm 2.14.3 Object-Relational-Mapper for PHP
doctrine/persistence 3.2.0 The Doctrine Persistence project is a set of shared interfaces and f...
doctrine/sql-formatter 1.1.3 a PHP SQL highlighting library
1条答案
按热度按时间eqoofvh91#
你至少需要2.9.0版的理论包