- Saved searches
- Use saved searches to filter your results more quickly
- dzhibas/rest-api-doc
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- Swagger-PHP
- Annotation and Attribute support
- 1. Install with composer: #
- 2. Update your code #
- 3. Generate OpenAPI documentation #
- 4. Explore and interact with your API #
- Links #
- Php what to write in api document
- Generate a DOC for a REST API
- Create REST API Documentation with Swagger UI using PHP, Part 4
- Write a RESTful API from Scratch using Plain, Object-Oriented PHP
- How to Create RESTful API in PHP
- How to document a Symfony based REST API (similar to enunciate’s documentation capabilities)
- Swagger PHP API Documentation (executing php files to make json)
- How should I write a web API that receives a file?
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Generates restful API documentation out of annotated php source files
dzhibas/rest-api-doc
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
RESTful api documentation build tool
script to build restful api documentation out of annotated PHP (for now) code. Output example you can find here
/** * @route /v1/modulename/authentication * @method POST * @ingroup modulename * * authentication service example * * HTTP response code tells about status of login: * * - 202: Request Accepted * - 401: Invalid username/password * - 403: Request Denied * - 503: Service Unavailable * * @example input * * POST /v1/modulename/authentication HTTP/1.1 * Content-Type: application/json; charset=utf-8 * * < * "username": "demousername", * "passwrod": "demopassword", * >* * @example output * * < * "message":"Request Accepted", * "id":386 * >* * @jsonparam username extranet username required * @jsonparam password extranet password required * * @returns json */
usage: restapidoc [-h] [-c] [-d DIR] [--filter FILTER] [-o OUTPUT] optional arguments: -h, --help show this help message and exit -c, --coverage ouputs into stdin documentation coverage -d DIR, --dir DIR folder in which we need look for documentation annotation. default: test_src_folder/ --filter FILTER gob filter in which files to search. default: *Controler*.php -o OUTPUT, --output OUTPUT output filename. default: documentation.html
About
Generates restful API documentation out of annotated php source files
Swagger-PHP
Using swagger-php lets you write the API documentation inside the PHP source files which helps keeping the documentation up-to-date.
Annotation and Attribute support
Annotations can be either docblocks or PHP 8.1 attributes.
1. Install with composer: #
> composer require zircote/swagger-php
2. Update your code #
Add swagger-php annotations or attributes to your source code.
use OpenApi\Annotations as OA; /** * @OA\Info( * title="My First API", * version="0.1" * ) */ class OpenApi > class MyController /** * @OA\Get( * path="/api/data.json", * @OA\Response( * response="200", * description="The data" * ) * ) */ public function getResource() // . > >
use OpenApi\Attributes as OA; #[OA\Info(title: "My First API", version: "0.1")] class OpenApi > class MyController #[OA\Get(path: '/api/data.json')] #[OA\Response(response: '200', description: 'The data')] public function getResource() // . > >
3. Generate OpenAPI documentation #
> ./bin/openapi src -o openapi.yaml
4. Explore and interact with your API #
Use an OpenAPI tool like Swagger UI to explore and interact with your API.
Links #
Php what to write in api document
Solution 2: To my knowledge there is no way to automate the documentation of media types. It also supports generating documentation for REST APIs.
Generate a DOC for a REST API
You might want to take a look at TechWriter for Web Services. It also supports generating documentation for REST APIs.
You can spent sometime to put DocBlock into all function/class you have built
A tool like PHPDOC is available for you to compile DocBlock into documentation and regenerate whatever you need (into your desired format).
Not to mention, is stored as static HTML
Can we insert html contents into google docs using, You want to upload an HTML file to Google Drive by converting it to Google Document using googleapis for PHP. In this case, how about the
Create REST API Documentation with Swagger UI using PHP, Part 4
This tutorial will give over the usage of OpenAPI GET, PUT, POST, and DELETE so you can Duration: 23:23
Write a RESTful API from Scratch using Plain, Object-Oriented PHP
Learn how to develop a complete, RESTful API using plain, object-oriented PHP, MySQL and Duration: 43:54
How to Create RESTful API in PHP
Missing: document ( | Must include:
How to document a Symfony based REST API (similar to enunciate’s documentation capabilities)
Not sure if you’ve seen Swagger before. They seem to have a PHP compatible version, though I can’t really vouch for it personally. It does some automatic API documentation generation comparable to enunciate, though it does look like it requires some heavy manual documentation via PHP comments. That being said, I think the manual effort will be the same or less than making your own via wiki pages, and the output is much, much nicer.
Just as a factoid, it looks like Enunciate has indefinite plans to eventually support other platforms, but the relevant Jira ticket is currently Open waiting for a sponsor to take on the work.
From the ENUNCIATE-356 Jira ticket:
The first step to supporting other languages is to decouple the Enunciate model from the Java model. This work is being tracked and logged at ENUNCIATE-584. Unfortunately, it never made it out of the investigate phase because of how heavy it is. Unless a sponsor for the work is found, I don’t anticipate taking that heavy load on anytime soon.
Edit:
Found a similar question where someone mentions a GitHub project dedicated to Swagger+Symfony2. This other question is the same, but no additional information.
To my knowledge there is no way to automate the documentation of media types.
If you are using a media type like XHTML then a web crawler like Google sitemap may produce some useful output to show the relations between your resources.
PHP REST API Tutorial (Step By Step) 7, 2 days ago · Welcome to the first video on Creating a simple REST API in PHP From Scratch. In this video Duration: 10:10 Posted: 2 days ago
Swagger PHP API Documentation (executing php files to make json)
There are two way to achieve this in swagger-php 2.0.
I. The first solution is to create a controller or script which will generate the documentation on each request. This is a good solution in a development environment where you want to see quickly the outcome of your changes.
Here is an example of a controller which does this.
, * swagger="2.0", * @SWG\Info( * version="1.0.0", * title="My API" * ) * ) * */ class Documentation < const API_PATH = "path/to/my/documented/files/"; public function show()< $swagger = Swagger\scan(self::API_PATH); return json_enconde($swagger); //you can echo this in the calling script. >>
Note: The example above assumes you installed Swagger-php with Composer and that the calling script include the composer generated autoload file (usually called: vendor/autoload.php ).
II. The first solution consisting of generating a static json API documentation is described here: https://stackoverflow.com/a/21380432/2853903
This solution recommended for production deployment, where you would not want to regenerate the documentation on every request.
How To Use Web APIs in PHP 8.0, In this tutorial, you’ll build a client for a RESTful API using HTTP POST and GET calls to interact with the server. You will build a web
How should I write a web API that receives a file?
I had to do something similar, and what I ended up doing was submitting the form to a hidden iframe. The response from the php can then simply be retrieved in an iframe onload handler.
In fact, here is the code I used:
$('submitdestination').onload=function()< var appID=this.contentDocument.body.children[0].innerHTML; //did something with appID new mBox.Notice(>);//displayed message > $('cvdetails').submit();
Note: submitdestination is my iframe. cvdetails is my form. The target for the form was set to submitdestination . Also, I am using Mootools, in case any one noticed the missing hash in my dollar arguments.
Here is a stripped down version of the HTML I used (although the iframe is unchanged):
The save button had a click handler that could be reduced to:
$('save').addEvent('click',function(evt))
Thanks to @Asad’s help I was able to get things working the way I wanted. Putting it all together, I have essentially this code:
window.onload = function() < setUploadID(-1); document.getElementById('hidden_iframe').onload = captureUploadID; >function setUploadID(id) < document.getElementById('upload_id').innerHTML = id; >function captureUploadID()
Upload ID:
Install Swagger UI Documentation for Your PHP RESTful API, Part 3, Now that we have looked at the custom PHP REST API, we need to create documentation. To Duration: 24:01