PHP code example of ke / apidoc

1. Go to this page and download the library: Download ke/apidoc 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/ */

    

ke / apidoc example snippets


// command.php
return [
    \app\command\ApiDoc::class,
];

// app/command/ApiDoc.php

namespace app\command;


use ke\apidoc\Parse;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\facade\App;

class ApiDoc extends Command
{
    public function configure()
    {
        $this->setName('apidoc');
    }


    public function execute(Input $input, Output $output)
    {
        (new Parse([
            'title'=>'XX接口文档',
            'api'=>false, // 如果需要json列表,赋予一个路径就可以
            'html'=>App::getRootPath() . 'api.html', // 设为false则不会生成html
        ]))->execute();
    }

}

php think apidoc

// command.php
return [
    \app\command\ApiDocComment::class,
];

// app/command/ApiDocComment.php

namespace app\command;


use ke\apidoc\MakeComment;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\facade\App;

class ApiDocComment extends Command
{
    public function configure()
    {
        $this->setName('apidoc:comment')
             ->addArgument('table', Argument::REQUIRED)
             ->addOption('prefix', 'p', Option::VALUE_OPTIONAL, '字段前缀');
    }


    public function execute(Input $input, Output $output)
    {
        $table = $input->getArgument('table');
        $prefix = $input->getOption('prefix');
        $info = (new MakeComment())->getComment($table, $prefix);
        $output->writeln('comment content:');
        $output->writeln($info);
    }

}

php think apidoc:comment health_school
or
# 使用-字段前缀
php think apidoc:comment health_school -p-