August 7, 2020
The OpenAPI generator can generate a PHP API clients as well as servers stubs for PHP (Laravel, Lumen, Slim, Silex, Symfony, Zend Expressive).
There are several ways to install the generator, as described in the docs. I used the method to clone the repository and build it myself.
To generate a PHP API client, use:
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
-i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml \
-g php \
-o /var/tmp/php_api_clientgit
You can display all options specific for your generator:
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar config-help -g php
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate \
-i https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/3_0/petstore.yaml \
-g php-laravel \
-o /var/tmp/php_api_laravel
TODO doesn't look as promising as the code that is generated with e.g the spring
generator to generate a server stub for Spring Boot. Need to investigate...