PHP的PSR-7 和 python 的 WSGI 的異同

來源:互聯網
上載者:User
關鍵字 psr-7 wsgi php python
目前在學PHP的Slim3架構,裡面有一個PSR-7的概念,看了一下,好像就是把原來的PHP的一些全域變數給封裝了一下,更OOP一點,之前也接觸過Django,感覺上和WSGI很像。不知道這兩個是不是就是一類東西。

回複內容:

目前在學PHP的Slim3架構,裡面有一個PSR-7的概念,看了一下,好像就是把原來的PHP的一些全域變數給封裝了一下,更OOP一點,之前也接觸過Django,感覺上和WSGI很像。不知道這兩個是不是就是一類東西。

好吧 來看看官網的描述你就知道了。

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本身提供的那些超全域變數,因為他們略顯拙劣。

  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    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.