PHP code example of mzh / hyperf-swagger

1. Go to this page and download the library: Download mzh/hyperf-swagger library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mzh / hyperf-swagger example snippets


// config/autoload/swagger.php  swagger 基础信息

declare(strict_types=1);

return [
    'output_file' => BASE_PATH . '/public/swagger.json',
    'swagger' => '2.0',
    'enable' =>true, // 是否启用web访问
    'info' => [
        'description' => 'hyperf swagger api desc',
        'version' => '1.0.0',
        'title' => 'HYPERF API DOC',
    ],
    'host' => 'hyperf.io',
    'schemes' => ['http']
];

php bin/hyperf.php vendor:publish mzh/hyperf-swagger

默开启文档web访问,如需关闭,在 config/autoload/swagger.php 将enable设为false 

// config/dependencies.php  重写 DispathcerFactory 依赖

declare(strict_types=1);

return [
    'dependencies' => [
        Hyperf\HttpServer\Router\DispatcherFactory::class => Mzh\Swagger\DispathcerFactory::class
    ],
];