未加星标

New in Symfony 3.3: WebServerBundle

字体大小 | |
[开发(php) 所属分类 开发(php) | 发布者 店小二05 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

Contributed by

Fabien Potencier in #21039 .

php 5.4 version introduced a built-in web server that can be used to run your PHP applications locally during development without the need to configure a full-featured web server such as Apache or Nginx.

Symfony adopted this technique a while ago by providing some console commands to control that web server . In Symfony 3.3 we decided to move those commands to a new bundle called WebServerBundle .

The main reason is that moving the commands make them more easily discoverable and more decoupled. Discoverability is specially important when not using the symfony/symfony dependency. In that case, the commands are not available unless you have the symfony/process component installed. With a dedicated bundle, installing the bundle also installs the dependency, making the whole process easier.

In any case, this new bundle won't change the way you work with the local web server:

# start a web server in the foreground and see the logs $ bin/console server:run # start, stop and manage a web server in the background $ bin/console server:start $ bin/console server:stop $ bin/console server:status

Creating a new bundle was also a great opportunity to introduce some DX (developer experience) improvements in those commands and make you more productive. First, you no longer need to pass the full address and port to the server:stop and server:status commands:

$ bin/console server:start 127.0.0.1:8888 ... # no need to pass the address again $ bin/console server:status # no need to pass the address again $ bin/console server:stop

That's possible because the web server now stores its address in a PID file stored in the current directory. In addition, the server:start command now looks for a free port available automatically :

Before Symfony 3.3: $ bin/console server:start [ERROR] A process is already listening on http://127.0.0.1:8000. $ bin/console server:start 127.0.0.1:8001 [ERROR] A process is already listening on http://127.0.0.1:8001. # ... 24 attempts later ... $ bin/console server:start 127.0.0.1:8024 [OK] Web server listening on http://127.0.0.1:8024 In Symfony 3.3: $ bin/console server:start [OK] Web server listening on http://127.0.0.1:8024

Unless you pass the port as argument, the server:start command now uses the first free port available starting from 8000 and up to 8100 .

本文开发(php)相关术语:php代码审计工具 php开发工程师 移动开发者大会 移动互联网开发 web开发工程师 软件开发流程 软件开发工程师

主题: PHPNginx
分页:12
转载请注明
本文标题:New in Symfony 3.3: WebServerBundle
本站链接:http://www.codesec.net/view/521449.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 开发(php) | 评论(0) | 阅读(77)