【发布时间】:2016-01-07 15:56:28
【问题描述】:
我正在尝试设置 Symfony3 microkelner 以与 FOSRestBundle 一起使用,但我遇到了一些问题。
我想将 json 或 xml 用作输入,也将 json 或 xml 用作输出。
我进行了一些设置,但遇到了错误:
ContainerBuilder.php 第 766 行中的 InvalidArgumentException: 服务定义“模板化”不存在。
和
ReplaceAliasByActualDefinitionPass.php 第 48 行中的 InvalidArgumentException: 无法将别名“模板”替换为“fos_rest.template”。
这就是我的 config.yml 的样子(带有模板和 fos_rest 的部分)
# Friends of Symfony REST
fos_rest:
disable_csrf_role: ROLE_API
view_response_listener: force
force_redirects:
html: true
param_fetcher_listener: true
body_listener:
decoders:
xml: fos_rest.decoder.xml
json: fos_rest.decoder.json
format_listener:
enabled: true
rules:
- { path: '^/', priorities: ['json', 'xml'], fallback_format: 'json', prefer_extension: false }
view:
formats:
xml: true
json: true
default_engine: json
failed_validation: HTTP_BAD_REQUEST
还有
templating:
engines: ['twig']
....
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
exception_controller: 'FOS\RestBundle\Controller\ExceptionController::showAction'
在 microkelner 中,我使用以下捆绑包:
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new FOS\RestBundle\FOSRestBundle(),
new JMS\SerializerBundle\JMSSerializerBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
);
if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
$bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle();
}
我使用的组件版本:
- FOSRestBundle:“1.7.7”
- Symfony:“3.0.0”
问题是如何正确设置它以消除此错误并使带有 microkelner 的 Symfony3 与 FOSRestBundle 一起使用?
谢谢。
【问题讨论】:
-
我面临同样的问题,有什么解决办法
标签: php fosrestbundle symfony