Next PHP implementation of RESTful style API example (ii)
. htaccess: Rewrite the URL so that the URL accesses the file in/RESTFUL/CLASS/1 form
Options +Followsymlinksrewriteengineon# rewrite rule rewriterule ^class$ index.php ? class=all [NC,^class/(\d+) $ index.php? Class=$1 [NC,QSA]
Create a new restful directory under the Apache web directory, and put the four files in the RESTful directory to access them.
These interfaces can be tested through interface testing tools, such as Firefox restclient, Chrome's Advanced Rest Client, Postman, and more.
Test method:
Get http://localhost/restful/class List all Classes GET http://localhost/ RESTFUL/CLASS/1 Get information about a given class POST http://Localhost/restful/class?name=sat class &count=23 new class PUT http://Localhost/restful/class/1?name=sat class &count=23 update information for designated classes (all information) PATCH http://Localhost/restful/class/1?name=sat class update information (part of information)DELETE http://LOCALHOST/RESTFUL/CLASS/1 Delete designated classes
SOURCE Download:https://github.com/lycheng423/RESTful
PHP implements RESTful API instances (iii)