PHP code example of alextech / expressive-route-openapi-doc

1. Go to this page and download the library: Download alextech/expressive-route-openapi-doc 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/ */

    

alextech / expressive-route-openapi-doc example snippets


use RouteApiDoc\RouterStrategy\RouterStrategyInterface;

return function (Application $app, MiddlewareFactory $factory, ContainerInterface $container) : void {
    // your API resources and handlers
    $app->get('/api/resources/:resource_id', []);
    $app->post('/api/resources', []);
    
    $apiWriter = $container->get(OpenApiWriter::class);
    $appWriter->addApplication($app);
    $apiWriter->writeSpec($app);
}