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:
1 2 3 4 5 6 7
# 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
DX improvements
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:
1 2 3 4 5 6 7 8
$ 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:
1 2 3 4 5 6 7 8 9 10
$ 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:
1 2
$ 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
.
Waiting for built in WebSocketBundle! :)
And MessageQueueBundle
WebSocket is nearly impossible in PHP without a persistent middleware behind it :) PHP is not made for persistent connections
thank you (y)
WebSocketBundle and MessageQueueBundle - really need for modern website. But all PHP developers have alternative like RabbitMQ or another framework like Node.js for appropriate tasks, but it's very uncomfortable to use so many technologies in one project. I think, in future, PHP can be behind the border if something does not change in core of language. For now Symfony is the best for me and I like it. However the future looks disappointing :(
Thank you.