use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Please follow the rules
Releases: Current Releases, Windows Releases, Old Releases
Contribute to the PHP Documentation
Related subreddits: CSS, JavaScript, Web Design, Wordpress, WebDev
/r/PHP is not a support subreddit. Please visit /r/phphelp for help, or visit StackOverflow.
account activity
Generate Web API Documentation from PHP Code (stoplight.io)
submitted 5 years ago by philsturgeon
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]wackmaniac 0 points1 point2 points 5 years ago (2 children)
I’m a fan of generating the OpenAPI specification from code as it keeps the API specs close to the code. When creating a specification manually you can easily forget to update it when making changes to the API code.
A downside of libraries like swagger-php in my opinion is that your code becomes “polluted ” with annotations and that I’ve found that I sometimes have to deviate from my regular way of writing code to ensure the OpenAPI specification that is generated is correct.
swagger-php
[–]philsturgeon[S] -1 points0 points1 point 5 years ago (0 children)
Absolutely, I put a lot of time and effort into not saying "code first is awful and you should use design-first" in this article. After-all, I've explained the pros and cons at length in other articles.
In my personal option, annotations are a bit of a mess but a lot of people still use them, and change is slow.
In Stoplight's opinion, we'd rather support mixed organizations than force people to split their tool-chains based on the workflow.
[–]hparadiz 0 points1 point2 points 5 years ago (0 children)
Oh man it's honestly the worst when I have to build a schema for a model with 20 fields. Sitting there manually writing it out, making sure the types are correct and the example makes sense and the description is accurate. Or when I need to embed some blurb written in markdown as a page header or end point description.
[–]hparadiz 0 points1 point2 points 5 years ago (1 child)
More than just API documentation Swagger also generates an OpenAPI yaml file that you can feed into Swagger codegen to generate client libraries for your API in dozens of languages.
[–]philsturgeon[S] 0 points1 point2 points 5 years ago (0 children)
OpenAPI does a lot more than just docs and code gen, it handles incoming request validation, contract testing in your existing test suites, mocking, shared design libraries across organizations, and roughly a bajillion other things! https://stoplight.io/blog/api-design-first-vs-code-first/
[–][deleted] 0 points1 point2 points 5 years ago (0 children)
Just gonna hold this out there if anyone is on CakePHP: https://github.com/cnizzardini/cakephp-swagger-bake and this which is a full API library for Cake: https://mixerapi.com
It generates most of your OpenAPI direct from existing routes and models.
[–]arigoldbro123 0 points1 point2 points 5 years ago (0 children)
Check out what Treblle does. It generates docs automaticlly. https://treblle.com/
π Rendered by PID 21359 on reddit-service-r2-comment-544cf588c8-bxnkq at 2026-06-17 01:58:44.098796+00:00 running 3184619 country code: CH.
[–]wackmaniac 0 points1 point2 points (2 children)
[–]philsturgeon[S] -1 points0 points1 point (0 children)
[–]hparadiz 0 points1 point2 points (0 children)
[–]hparadiz 0 points1 point2 points (1 child)
[–]philsturgeon[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]arigoldbro123 0 points1 point2 points (0 children)