PHPackages                             doanphu/swagger-php-trigger-error - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. doanphu/swagger-php-trigger-error

ActiveLibrary[API Development](/categories/api)

doanphu/swagger-php-trigger-error
=================================

swagger-php - Generate interactive documentation for your RESTful API using phpdoc annotations

035PHP

Since Oct 19Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Doanphuxm01/zircote-swagger-php-trigger_error)[ Packagist](https://packagist.org/packages/doanphu/swagger-php-trigger-error)[ RSS](/packages/doanphu-swagger-php-trigger-error/feed)WikiDiscussions doanphu Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

[![Build Status](https://camo.githubusercontent.com/bc8d8fb088bb0b25efc5403d66a1a1a5ffc6250c201a4d95511693ccc6311133/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7a6972636f74652f737761676765722d7068702f6275696c643f7374796c653d666c61742d737175617265)](https://github.com/zircote/swagger-php/actions?query=workflow:build)[![Total Downloads](https://camo.githubusercontent.com/2afe22c8f1ef1afa1f6bf3bcbd1698a7c018f8c1f6e6d37854e5b765cea693ba/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a6972636f74652f737761676765722d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zircote/swagger-php)[![License](https://camo.githubusercontent.com/b89cba305c99c2dfde6231572de7b70bd58c854ee6ca8c2b6c8b1a92a51d6426/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865322e302d626c75652e7376673f7374796c653d666c61742d737175617265)](LICENSE)

swagger-php
===========

[](#swagger-php)

Generate interactive [OpenAPI](https://www.openapis.org) documentation for your RESTful API using [doctrine annotations](https://www.doctrine-project.org/projects/doctrine-annotations/en/latest/index.html).

For a full list of supported annotations, please have look at the [`OpenApi\Annotations` namespace](src/Annotations) or the [documentation website](https://zircote.github.io/swagger-php/guide/annotations.html).

Features
--------

[](#features)

- Compatible with the OpenAPI **3.0** and **3.1** specification.
- Extracts information from code &amp; existing phpdoc annotations.
- Command-line interface available.
- [Documentation site](https://zircote.github.io/swagger-php/) with a getting started guide.
- Exceptional error reporting (with hints, context)
- As of PHP 8.1 all annotations are also available as PHP attributes

OpenAPI version support
-----------------------

[](#openapi-version-support)

`swagger-php` allows to generate specs either for **OpenAPI 3.0.0** or **OpenAPI 3.1.0**. By default the spec will be in version `3.0.0`. The command line option `--version` may be used to change this to `3.1.0`.

Programmatically, the method `Generator::setVersion()` can be used to change the version.

Requirements
------------

[](#requirements)

`swagger-php` requires at least PHP 7.2 for annotations and PHP 8.1 for using attributes.

Installation (with [Composer](https://getcomposer.org))
-------------------------------------------------------

[](#installation-with-composer)

```
composer require doanphu/swagger-php-trigger-error
```

For cli usage from anywhere install swagger-php globally and make sure to place the `~/.composer/vendor/bin` directory in your PATH so the `openapi` executable can be located by your system.

```
composer global require zircote/swagger-php
```

Usage
-----

[](#usage)

Add annotations to your php files.

```
/**
 * @OA\Info(title="My First API", version="0.1")
 */

/**
 * @OA\Get(
 *     path="/api/resource.json",
 *     @OA\Response(response="200", description="An example resource")
 * )
 */
```

Visit the [Documentation website](https://zircote.github.io/swagger-php/) for the [Getting started guide](https://zircote.github.io/swagger-php/Getting-started.html) or look at the [Examples directory](Examples/) for more examples.

### Usage from php

[](#usage-from-php)

Generate always-up-to-date documentation.

```
