Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report

zircote/swagger-php 4.8.3

swagger-php - Generate interactive documentation for your RESTful API using phpdoc annotations
Package summary
Share
0
issues
0
licenses
Package created
19 Apr 2012
Version published
7 Jan 2024
Maintainers
3
Total deps
0
Direct deps
0
License
Apache-2.0
Generating a report...
Hold on while we generate a fresh audit report for this package.

Frequently Asked Questions

What does zircote/swagger-php do?

The Zircote/Swagger-PHP is a powerful composer package designed for automatic generation of interactive OpenAPI documentation for your RESTful APIs by using PHPDoc annotations. The tool is compatible with OpenAPI 3.0 and 3.1 specifications and is capable of extracting information from code and existing PHPDoc annotations. Zircote/Swagger-PHP is known for its exceptional error reporting and as of PHP 8.1, all its annotations are available as PHP attributes.

How do you use zircote/swagger-php?

To take advantage of Zircote/Swagger-PHP in your project, you can install it with Composer with the command composer require zircote/swagger-php. You can then add the necessary annotations to your PHP files, defining the information that you want to include in your API documentation. For instance:

    /**
     * @OA\Info(title="My First API", version="0.1")
     */
    
    /**
     * @OA\Get(
     *     path="/api/resource.json",
     *     @OA\Response(response="200", description="An example resource")
     * )
     */

To generate and display your documentation, you just need to call the appropriate methods as in the below example:

   <?php
   require("vendor/autoload.php");
   $openapi = \OpenApi\Generator::scan(['/path/to/project']);
   header('Content-Type: application/x-yaml');
   echo $openapi->toYaml();

You may set the version of your OpenAPI documentation using the Generator::setVersion() method. Also, you can utilize the command-line interface that's offered by Zircote/Swagger-PHP to generate the documentation into a static file.

Where are the zircote/swagger-php docs?

The full details of how to use the Zircote/Swagger-PHP package, including a comprehensive list of supported annotations, are available on the official documentation website. The website features a getting started guide, a guide to using the annotations, information on how to use the Generator class and much more. To dive deeper into real world examples, you can browse the Examples directory in the package's repository on GitHub.