====== PHP RFC: Add HTTP/2 Support to the CLI Server ====== * Version: 0.1 * Date: 2016-01-08 * Author: Davey Shafik, davey@php.net * Status: Draft * First Published at: http://wiki.php.net/rfc/cli_server_http2 ===== Introduction ===== As more clients support HTTP/2 (e.g. 60% of browsers, curl, etc) we run into [[https://github.com/php/php-src/pull/1692#issuecomment-166939909|the issue]] of not being able to test new HTTP/2 functionality being added to PHP without external dependencies (e.g. a web server). To solve this, it has been proposed that we update the cli-server to support HTTP/2. ===== Proposal ===== For supporting HTTP/2, it is pretty well agreed ((see references)) that we should use a third party library to implement it, with libnghttp2 being my proposed suggestion. We should ship with some self signed certs (it's for development only, remember!) that can be used to setup SSL, as no browser supports plain text HTTP/2. Given that this introduces a new required dependency there are two ways we can implement this functionality: - Make it optional, allowing you to build the current HTTP/1.x cli-server and requiring no additional dependency - Make it required, but this also effectively requires libopenssl It should be noted that libnghttp2 is also used by both curl and Apache 2, making it more likely that you already have it With either implementation, we can also make HTTP/2 always enabled (if built in), or we can make it de/activated with a flag, such as: ''--[no-]http2''. I believe we **should** have this flag as it makes it possible to test HTTP/1.x fallback for HTTP/2 clients, as well as HTTP/2. In addition, we should consider adding the HTTP/2 ''SETTINGS'' to ''$_SERVER'' so we can both detect that the request is using HTTP/2 and make intelligent decisions on how the application performs (e.g. server push of multiple CSS files vs minifying/concatenating). We should also support the ability to do server push using HTTP headers (current community thinking is leaning towards ''Link: ; rel=preload'' header) ===== Backward Incompatible Changes ===== If we make this required for cli-server, then the new dependency requirement could be considered a BC break ===== Proposed PHP Version(s) ===== Next 7.x ===== RFC Impact ===== Adds a newly required dependency, libnghttp2 ==== To SAPIs ==== Adds HTTP/2 support to cli-server, potentially with a new flag. Meaning you could start the server like so: ''php -S 0.0.0.0:8080 --http2 -t ./public/ ./public/index.html'' ==== To Existing Extensions ==== None ==== To Opcache ==== I do not believe this will affect opcache in any way ===== Open Issues ===== ===== Unaffected PHP Functionality ===== ===== Future Scope ===== ===== Proposed Voting Choices ===== ===== Patches and Tests ===== None yet, help needed ===== Implementation ===== After the project is implemented, this section should contain - the version(s) it was merged to - a link to the git commit(s) - a link to the PHP manual entry for the feature ===== References ===== - [[https://github.com/php/php-src/pull/1692#issuecomment-166997916|Suggestion to use nghttp2]], as well as [[http://news.php.net/php.internals/89932|on internals]] - [[http://news.php.net/php.internals/90016|Support from Pierre]] - [[http://news.php.net/php.internals/90038|Agreement from Andrea]] ===== Rejected Features ===== Keep this updated with features that were discussed on the mail lists.