Home Backend Development PHP Tutorial PHP REST架构简略设计

PHP REST架构简略设计

Jun 13, 2016 am 10:30 AM
get public rest user

PHP REST架构简单设计

  • REST是什么?

REST(Representational State Transfer表述性状态转移)是一种针对网络应用的设计和开发方式,可以降低开发的复杂性,提高系统的可伸缩性。

  • REST的特点:

  1. 网络上的所有事物都被抽象为资源(resource)
  2. 每个资源对应一个唯一的资源标识(resource identifier)
  3. 通过通用的连接器接口(generic connector interface)对资源进行操作;
  4. 对资源的各种操作不会改变资源标识;
  5. 所有的操作都是无状态的(stateless)。
  • REST的通俗说明:

  1. REST是通过HTTP请求的状态,去服务器端请求不同的服务方法,但是请求地址是相同的。比如请求一个http://xxxxx.com/user/的接口为例
  2. 例如POST方法,一般提供数据新增的功能,如果客户端是POST方法,请求上面的接口,那就是告诉服务器,是新增的操作。
  3. 例如GET方法,一般是获取数据,因为GET方法是默认的方法,不会对数据造成改变,所以一般是获取数据,通过GET方法请求上面的接口,就是获取用户数据
  4. 例如PUT方法,一般是更新操作,告诉服务器,更新用户信息。
  5. 例如DEL方法,一般是删除操作。
  6. 通过HTTP的4中请求方法,就可以在同一个接口地址上产生四种不同的请求,对接口的扩展性提供了巨大的帮助。
  • REST PHP端代码简单实现:



参考:百度,InitPHP框架REST实现


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to automate tasks using PowerShell How to automate tasks using PowerShell Feb 20, 2024 pm 01:51 PM

If you are an IT administrator or technology expert, you must be aware of the importance of automation. Especially for Windows users, Microsoft PowerShell is one of the best automation tools. Microsoft offers a variety of tools for your automation needs, without the need to install third-party applications. This guide will detail how to leverage PowerShell to automate tasks. What is a PowerShell script? If you have experience using PowerShell, you may have used commands to configure your operating system. A script is a collection of these commands in a .ps1 file. .ps1 files contain scripts executed by PowerShell, such as basic Get-Help

What is the difference between the developer version and the public version of iOS? What is the difference between the developer version and the public version of iOS? Mar 01, 2024 pm 12:55 PM

Every year before Apple releases a new major version of iOS and macOS, users can download the beta version several months in advance and experience it first. Since the software is used by both the public and developers, Apple has launched developer and public versions, which are public beta versions of the developer beta version, for both. What is the difference between the developer version and the public version of iOS? Literally speaking, the developer version is a developer test version, and the public version is a public test version. The developer version and the public version target different audiences. The developer version is used by Apple for testing by developers. You need an Apple developer account to download and upgrade it.

Flask-RESTPlus: Solve the Chinese garbled problem of RESTful API Flask-RESTPlus: Solve the Chinese garbled problem of RESTful API Jun 17, 2023 pm 10:26 PM

With the rapid development of the Internet, more and more web applications are beginning to utilize RESTful API to provide data services. When using RESTful API, the problem of Chinese garbled characters has become a headache for developers. Flask-RESTPlus was born to solve this problem. Flask-RESTPlus is an extension of the Flask framework, which provides a set of RESTful API rapid construction tools based on the Swagger standard. with Flask-RE

How does java initiate an http request and call the post and get interfaces? How does java initiate an http request and call the post and get interfaces? May 16, 2023 pm 07:53 PM

1. Java calls post interface 1. Use URLConnection or HttpURLConnection that comes with java. There is no need to download other jar packages. Call URLConnection. If the interface response code is modified by the server, the return message cannot be received. It can only be received when the response code is correct. to return publicstaticStringsendPost(Stringurl,Stringparam){OutputStreamWriterout=null;BufferedReaderin=null;StringBuilderresult=newSt

How to solve the problem of docker mounting directory permissions How to solve the problem of docker mounting directory permissions Feb 29, 2024 am 10:04 AM

In Docker, the permission problem of the mounting directory can usually be solved by the following method: adding permission-related options when using the -v parameter to specify the mounting directory. You can specify the permissions of the mounted directory by adding: ro or :rw after the mounted directory, indicating read-only and read-write permissions respectively. For example: dockerrun-v/host/path:/container/path:roimage_name Define the USER directive in the Dockerfile to specify the user running in the container to ensure that operations inside the container comply with permission requirements. For example: FROMimage_name#CreateanewuserRUNuseradd-ms/bin/

Example of Curl Get command Example of Curl Get command Mar 20, 2024 pm 06:56 PM

In Linux, URL or Curl client is a popular command line utility that allows you to transfer data over the network using various protocols such as HTTPS, HTTP, FTP, etc. It allows you to send and receive data using its get, post and request methods. Among them, you need to use the "get" method frequently. Therefore, it becomes crucial to learn various methods and various options that you can use to increase your productivity. "Performing a curl operation is as simple as entering a few simple commands. Although it seems simple, many users do not fully realize its potential. Therefore, this short guide provides some information on how to perform curl operations on Linux systems. Example using the "curlget" command." Curl

Common Mistakes in Java JAX-RS: Reveal and Avoid Potential Pitfalls Common Mistakes in Java JAX-RS: Reveal and Avoid Potential Pitfalls Feb 29, 2024 pm 02:16 PM

1. Ignore the annotations of resource classes. In JAX-RS, resource classes need to use the @Path annotation to specify their URI path. Without this annotation, the framework will not recognize that the class is a resource class, resulting in inability to access its methods. Example: @Path("/products")publicclassProductResource{//...} 2. Forgot to provide media type JAX-RS method needs to specify the media type it supports, using @Produces and @Consumes annotations. If not specified, the framework will not be able to negotiate the media types returned or accepted. Example: @GET@Produces(MediaType.APPLICATioN_

How to change Ubuntu's apt-get update source? How to change Ubuntu's apt-get update source? Jan 05, 2024 pm 03:40 PM

Manually modify Ubuntu's apt-get source 1. Use the ssh tool to connect to Ubuntu (I use xshell) 2. Type cd/etc/apt/3 on the command line and back up the source.list file in this directory (you must have sudo permissions) ), then there is a source.list.bak file. 4. Clear the source.list file content (note: it cannot be restored after clearing, so you need to perform the previous step to back up the file in advance). At this time, use sudo to prompt that the permissions are insufficient. Switch directly to the root user and execute this command. 5. Use vim to open source.list, press the i key to enter the editing mode, paste the source address to be modified, and then press

See all articles