我正在尝试设置Symfony3 microkelner来使用FOSRestBundle,而且我也遇到了一些问题。
我希望将其用作输入json或xml,并用作输出( json或xml )。
我做了一些设置,我面临错误:
InvalidArgumentException在ContainerBuilder.php第766行中:服务定义“模板”不存在。
和
InvalidArgumentException在ReplaceAliasByActualDefinitionPass.php第48行中:无法将别名“模板”替换为"fos_rest.templating“。
这就是我的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();
}我使用的组件的版本:
问题是如何正确设置它以消除此错误,并使Symfony3与microkelner一起使用FOSRestBundle?
谢谢。
发布于 2016-04-13 13:30:40
你确定你的配置是正确的吗?当我用以下方法转储容器时:
$ bin/console debug:container | grep fos我在许多其他文字中看到:
fos_rest.templating alias for "templating" 因此,fos_rest.templating只是templating的别名,这可能就是为什么您可以用自己来替换它,因此这两个错误。
https://stackoverflow.com/questions/34659557
复制相似问题