New in Symfony 3.3: WebServerBundle
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开发工程师 软件开发流程 软件开发工程师