avtehnik / service-doc
service-doc - Generate interactive documentation for your RESTful API using phpdoc annotations
Installs: 7 753
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Language:JavaScript
Requires
- php: >=7.1
- doctrine/annotations: *
- symfony/finder: >=2.2
- symfony/yaml: >=3.3
Requires (Dev)
- phpunit/phpunit: >=8
- squizlabs/php_codesniffer: >=3.3
- zendframework/zend-form: <2.8
This package is auto-updated.
Last update: 2025-03-12 16:30:18 UTC
README
composer require avtehnik/service-doc
Usage
Add annotations to your php files.
/** * @ServiceDoc\Info(title="My First API", version="0.1") */ /** * @ServiceDoc\PathItem( * microservice="payment", * path="/wallet-prices", * method="get", * @ServiceDoc\Tag( * name="user", * ) * ) * @param $destination_code * @param $source_code * * @return */
Usage from Yii
Add servicedoc section to actions array
class DocumentationController extends Controller { public function actions() { return [ 'servicedoc' => [ 'class' => 'ServiceDoc\YiiServiceDocAction', 'scanDir' => [ Yii::getAlias('@common/components') ], ], ]; } }
and then you can access to docs with url /documentation/servicedoc
Usage from php
Generate always-up-to-date documentation.
<?php require("vendor/autoload.php"); $swagger = \ServiceDoc\scan(__DIR__); header('Content-type: application/json; charset=utf-8'); echo $swagger->toJson();