PHP code example of baoziyoo / hyperf-api-doc

1. Go to this page and download the library: Download baoziyoo/hyperf-api-doc 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/ */

    

baoziyoo / hyperf-api-doc example snippets


use Baoziyoo\Hyperf\ApiDocs\Annotation\Api;
use Baoziyoo\Hyperf\ApiDocs\Annotation\ApiHeader;
use Baoziyoo\Hyperf\ApiDocs\Annotation\ApiOperation;

#[Api(tags: 'demo管理')]
#[ApiHeader('token')]
#[ApiHeader('tokenType')]
class DemoController extends AbstractController
{
    #[ApiOperation('登陆')]
    public function index(#[RequestQuery] DemoQuery $request): Contact
    {
        $contact = new Contact();
        $contact->name = $request->name;
        var_dump($request);
        return $contact;
    }

    #[ApiOperation('更新token')]
    public function add(#[RequestBody] DemoBodyRequest $request, #[RequestQuery] DemoQuery $query)
    {
        var_dump($query);
        return json_encode($request, JSON_UNESCAPED_UNICODE);
    }

    public function fromData(#[RequestFormData] DemoFormData $formData): bool
    {
        $file = $this->request->file('photo');
        var_dump($file);
        var_dump($formData);
        return true;
    }
}
shell
composer f.php vendor:publish baoziyoo/hyperf-api-doc