素材牛VIP会员
PHP的PSR-7 和 python 的 WSGI 的异同
 13***62  分类:Python  人气:959  回帖:1  发布于6年前 收藏

目前在学PHP的Slim3框架,里面有一个PSR-7的概念,看了一下,好像就是把原来的PHP的一些全局变量给封装了一下,更OOP一点,之前也接触过Django,感觉上和WSGI很像。不知道这两个是不是就是一类东西。

 标签:wsgipsr-7pythonphp

讨论这个帖子(1)垃圾回帖将一律封号处理……

Lv5 码农
em***co PHP开发工程师 6年前#1

好吧 来看看官网的描述你就知道了。

1.WSGI

WSGI is the Web Server Gateway Interface. It is a specification that describes how a web server communicates with web applications, and how web applications can be chained together to process one request.
WSGI is a Python standard described in detail in PEP 3333.

  1. PSR-7

PSR-7: HTTP message interfaces
This document (HTTP message desribetion) describes common interfaces for representing HTTP messages as described in RFC 7230 and RFC 7231, and URIs for use with HTTP messages as described in RFC 3986.

应该能够看出来差别了。

WSGI是一个 Web Server Gateway Interface ,也就是 服务器网关接口 ,这玩意描述了 Web server怎么样和你的python cgi程序之间交流,说说话啥的,我这边有啥任务了,你来做,做完了把结果告诉我,我告诉浏览器那家伙去。

那么 PSR-7 呢?它是 PSR 家族的一个最新的成员,是一个 HTTP message interfaces 。对,这就和python 和 php 之间作为web开发语言之间的差异有关系了。 也就是说, PSR-7 定义了一套标准,来标准化使用PHP来进行HTTP通信,替换PHP本身提供的那些超全局变量,因为他们略显拙劣。

 文明上网,理性发言!   😉 阿里云幸运券,戳我领取