Akihito Nakano 6d6ef0f120 [PHP] Refactor php client generator (#504)
* Extends AbstractPhpCodegen instead of DefaultCodegen

* Remove fully duplicated methods with AbstractPhpCodegen

* Remove duplicated properties with AbstractPhpCodegen

* Remove duplicated codes in constructor with AbstractPhpCodegen

* Add typeMapping "date". Moved from PhpClientCodegen

refs: 3c34c0b377 (diff-f1801ef05a7926bf394c90f44ae4ab3dL132)

* Remove duplicated codes in processOpts()

* Remove unnecessary 'implements'

* Remove unnecessary method override

* Use setter

* Merge getTypeDeclaration() into AbstractPhpCodegen

* Merge processOpts() into AbstractPhpCodegen

refs:
* 296e6d3db4 (diff-f1801ef05a7926bf394c90f44ae4ab3dL139)
* 296e6d3db4 (diff-f1801ef05a7926bf394c90f44ae4ab3dL147)
* 296e6d3db4 (diff-f1801ef05a7926bf394c90f44ae4ab3dL153)

* tweak

* Optimize IF statement

* Remove duplicated methods

* Merge setParameterExampleValue() into AbstractPhpCodegen

* Merge toEnumVarName() into AbstractPhpCodegen

* Merge toEnumName() into AbstractPhpCodegen

* Merge escapeUnsafeCharacters() into AbstractPhpCodegen

* Merge postProcessOperationsWithModels() into AbstractPhpCodegen

* tweak

* Recover missing method

refs: 2ad0f6f7d4 (diff-f1801ef05a7926bf394c90f44ae4ab3dL91)

* Tweak test case

refs: 4e7b7afc1a

* Remove unnecessary 'import'

* Update lumen and ze-ph samples

- ./bin/php-lumen-petstore-server.sh > /dev/null 2>&1
- ./bin/php-ze-ph-petstore-server.sh > /dev/null 2>&1

* Update slim samples

* Fix script name

* Update silex samples

* Update kotlin-server
2018-07-17 09:27:02 +08:00
..

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:

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 ./public and 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 found for unknown routes
  • 406 Not acceptable for invalid Accept header
  • 415 Unsupported media type for invalid Content-Type header
  • 400 Malformed JSON for unparsable JSON body
  • 422 Unprocessable entity for 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.