我开始这样安装:
https
://symfony.com/doc/4.x/bundles/NelmioApiDocBundle/index.html
第1步。
`composer require nelmio/api-doc-bundle` - Thats OK
第2步。
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
new Nelmio\ApiDocBundle\NelmioApiDocBundle(),
];
}
}
但是我没有 AppKernel 扩展内核。我**只有内核**和
`$contents = require $this->getProjectDir().'/config/bundles.php';`
所以我添加到**/config/bundles.php**
Nelmio\ApiDocBundle\NelmioApiDocBundle::class => ['all' => true],
步骤 3.
我添加到config/routes.yaml
# config/routes.yaml
app.swagger_ui:
path: /api/doc
methods: GET
defaults: { _controller: nelmio_api_doc.controller.swagger_ui }
第 4 步。
我创建了config /packages/nelmio_api_doc.yaml
nelmio_api_doc:
areas:
path_patterns: # an array of regexps
- ^/api(?!/doc$)
host_patterns:
- ^api\.
之后,我应该在 mysite/api/doc 上看到 Swagger 的页面
但我在 github 上只看到带有链接“NelmioApiDocBundle”的白页
我做错了什么?