我正在使用Symfony 3.4,我想添加Api平台。 安装完最后一个(API)之后,当我尝试调试路由时,看不到以api /开头的路由 我不知道怎么了 感谢给我一些建议
这是我的composer.json
"require": {
"php": ">=5.5.9",
"api-platform/api-pack": "^1.2",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
"easycorp/easyadmin-bundle": "^1.17",
"incenteev/composer-parameter-handler": "^2.0",
"nelmio/api-doc-bundle": "^3.4",
"sensio/distribution-bundle": "^5.0.19",
"sensio/framework-extra-bundle": "^5.0.0",
"symfony/dependency-injection": "3.4.*",
"symfony/flex": "1.2.3",
"symfony/monolog-bundle": "^3.1.0",
"symfony/polyfill-apcu": "^1.0",
"symfony/swiftmailer-bundle": "^2.6.4",
"symfony/symfony": "3.4.*",
"twig/twig": "^1.0||^2.0"
},
答案 0 :(得分:1)
很好看#stephan.mada的答案,我说我正在使用软件包的配置,现在我选择了
... api_platform: 映射: 路径:['%kernel.project_dir%/ src / Entity'] ...
来自
到
与路线相同
我感动
api_platform: 资源:。 类型:api_platform
来自
到
现在到了,感谢大家的宝贵帮助
答案 1 :(得分:0)
我不知道它是否已经在您的项目中完成,但是要使API平台正常工作,您需要:
// app/AppKernel.php
$bundles = [
// ...
new ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle(),
];
# app/config/config.yml
api_platform:
mapping:
paths: ['%kernel.project_dir%/src/Entity']
# app/config/routing.yml
api_platform:
resource: .
type: api_platform
prefix: /api
<?php
// src/AppBundle/Entity/Book.php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
/**
* ...
*
* @ApiResource
*/
class Book
{
// ...
}