Download the PHP package spiral-packages/swagger-php without Composer
On this page you can find all versions of the php package spiral-packages/swagger-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download spiral-packages/swagger-php
More information about spiral-packages/swagger-php
Files in spiral-packages/swagger-php
Package swagger-php
Short Description Swagger-php integration package for Spiral Framework.
License MIT
Homepage https://github.com/spiral-packages/swagger-php
Informations about the package swagger-php
Swagger-php
zircote/swagger-php integration package for Spiral Framework.
Requirements
Make sure that your server is configured with following PHP version and extensions:
- PHP 8.1+
- Spiral framework 3.5+
Installation
You can install the package via composer:
To enable the package in your Spiral Framework application, you will need to add
the Spiral\OpenApi\Bootloader\SwaggerBootloader
class to the list of bootloaders in your application:
Note If you are using
spiral-packages/discoverer
, you don't need to register bootloader by yourself.
Configuration
The configuration file should be located at app/config/swagger.php
, and it allows you to set options.
Here is an example of how the configuration file might look:
Usage
First, create an entity that represents the resource you want to document. For example, you can create a User entity that represents a user resource:
Next, create a Controller that handles the actions for the resource, and add Swagger attributes to the actions to describe the behavior of the endpoint. For example, you can create a UserController that handles the list action for the User resource:
Some elements like page, limit, direction parameters. The ResponseCollectionMeta schema can be used in a variety of places. Therefore, they can be defined in the configuration file:
The package provides a Spiral\OpenApi\Controller\DocumentationController
controller that can render
the documentation in various formats such as HTML, JSON, and YAML. The HTML format uses the Swagger UI
for displaying
the documentation. To use this controller, it is necessary to add a route
in the App\Application\Bootloader\RoutesBootloader
file:
Testing
License
The MIT License (MIT). Please see License File for more information.
All versions of swagger-php with dependencies
spiral/boot Version ^3.5
spiral/config Version ^3.5
spiral/core Version ^3.5
spiral/views Version ^3.5
spiral/cache Version ^3.5
spiral/http Version ^3.5
zircote/swagger-php Version ^4.8