如何在 api-platform 中为不同的 bundle 配置不同的前缀 [英] How to configure different prefixes for different bundles in api-platform

查看:23
本文介绍了如何在 api-platform 中为不同的 bundle 配置不同的前缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

控制台命令 debug:router 绝对显示所有资源,来自所有已安装的 Bundle(实体标记为 @ApiResource())

Console command debug:router show absolutely ALL resources, from all installed Bundles (entity marked with @ApiResource())

如何为不同的bundle配置不同的前缀?或者有选择地禁用资源.

How to configure different prefixes for different bundles? Or selectively disable resources.

App 忽略了 resource 中的任何路径:config/routes/api_platform.yaml

App ignored any path in resource: config/routes/api_platform.yaml

api_platform:
    resource: .
    type: api_platform
    prefix: /api

使用默认配置 config/packages/api_platform.yaml

api_platform:
  mapping:
    paths: ['%kernel.project_dir%/src/Entity']

推荐答案

https://github.com/api-platform/core/blob/5882990beaf75675170efb54384bf44c3534dd1b/src/Bridge/Symfony/Routing/ApiLoader.php

对于 type: api_platform resource: . not used

For type: api_platform resource: . not used

自动资源加载只能完全禁用

Automatic resource loading can only be disabled completely

  doctrine:
    enabled: false

这篇关于如何在 api-platform 中为不同的 bundle 配置不同的前缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆