forked from loafle/openapi-generator-original
* [PHP] Remove PHP related rules from root gitignore After conversation with @ackintosh we've agreed that every PHP codegen should create it's own `.gitignore`. Client libraries(SDKs) should ignore `composer.lock` file while server stubs better do opposite. * [PHP] Set .gitignore as default supporting file * [PHP] Add default gitignore to Client SDK * [PHP] Add default gitignore to Laravel * [PHP] Add default gitignore to Lumen * [PHP] Add default gitignore to Silex Seems like issue #663 and pull request #681 missed this security script, I've changed output path in bin/security/silex-petstore-server.sh. * [PHP] Update Slim * [PHP] Add default gitignore to Symfony I've copied few old rules from root gitignore to local one. These rules should be reviewed by original SymfonyCodegen authors. * [PHP] Add default gitignore to Zend * [PHP] Refresh Openapi3 client samples * [PHP] Add refs to .gitignore templates collection
OpenAPI generated server
Generated by the OpenAPI Generator project.
Overview
This server stub aims to provide light, yet comprehensive structure for your API project using:
- PHP: 5.6 or 7.*
- Zend Expressive: 2.1
- Path Handler: 0.3
How to use
All you have to do to start development is:
- install dependencies via Composer
- create cache folder:
mkdir -p ./data/cache/ZendCache(you will need it later for configuration and metadata caches - check comments in./application/config.yml) - start PHP development server:
php -S 0.0.0.0:8080 -t ./public(or any other SAPI you prefer, just make sure that you configure webroot to./publicand rewrites to./public/index.php)
After that you should be able to call all methods from your API spec. Most of the negative scenarios should be handled:
404 Not foundfor unknown routes406 Not acceptablefor invalidAcceptheader415 Unsupported media typefor invalidContent-Typeheader400 Malformed JSONfor unparsable JSON body422 Unprocessable entityfor parsable JSON body that fails validation
But for obvious reason you will not get any 200 OK, only 500 Not implemented. So your next steps are:
- check all TODOs left in the stub code where generator was not smart enough and could not guarantee correct implementation
- implement your API security mechanism (either special attribute or separate middleware) - generator does not do anything about it yet
- implement your handlers - the most tricky part :)
Enjoy!
Hopefully this stub will reduce the amount of boilerplate code you have to write manually. If you have any suggestions or questions about ze-ph generator, feel free to create issue either in Path Handler repository or in OpenAPI Generator repository.