PHP implements RESTful API instances (iii)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.