@@ -15,8 +15,11 @@ a full-featured web server such as
15
15
The built-in web server is meant to be run in a controlled environment.
16
16
It is not designed to be used on public networks.
17
17
18
+ Running the Server in the Foreground
19
+ ------------------------------------
20
+
18
21
Starting the Web Server
19
- -----------------------
22
+ ~~~~~~~~~~~~~~~~~~~~~~~
20
23
21
24
Running a Symfony application using PHP's built-in web server is as easy as
22
25
executing the ``server:run `` command:
@@ -37,7 +40,7 @@ can change the socket passing an ip address and a port as a command-line argumen
37
40
$ php app/console server:run 192.168.0.1:8080
38
41
39
42
Command Options
40
- ---------------
43
+ ~~~~~~~~~~~~~~~
41
44
42
45
The built-in web server expects a "router" script (read about the "router"
43
46
script on `php.net `_) as an argument. Symfony already passes such a router
@@ -58,3 +61,61 @@ you have to pass the correct location using the ``--docroot`` option:
58
61
59
62
.. _`built-in web server` : http://www.php.net/manual/en/features.commandline.webserver.php
60
63
.. _`php.net` : http://php.net/manual/en/features.commandline.webserver.php#example-401
64
+
65
+ Moving the Process to the Background
66
+ ------------------------------------
67
+
68
+ .. versionadded :: 2.6
69
+ The ability to run the server as a background process was introduced
70
+ in Symfony 2.6.
71
+
72
+ The ``server:run `` command runs the web server in the foreground blocking
73
+ the current terminal window. You can also run the server in a background process:
74
+
75
+ .. code-block :: bash
76
+
77
+ $ php app/console server:start
78
+
79
+ The ``server:start `` command accepts the same options and arguments as the
80
+ ``server:run `` command. For example, the following command will tell the server
81
+ to listen on port 8080 on the network interface with the 192.168.0.1 ip address
82
+ assigned to:
83
+
84
+ .. code-block :: bash
85
+
86
+ $ php app/console server:start 192.168.0.1:8080
87
+
88
+ This way, you can start several server processes listening on different sockets
89
+ without bothering with a clutter of terminal windows.
90
+
91
+ Stopping the Server
92
+ ~~~~~~~~~~~~~~~~~~~
93
+
94
+ To stop a server running in the background, you simply call the ``server:stop ``
95
+ command passing it the socket the server is listening on.
96
+
97
+ .. code-block :: bash
98
+
99
+ $ php app/console server:stop 127.0.0.1:8080
100
+
101
+ Similar to the commands that are used to start the web server, omitting the
102
+ socket argument for the ``server:stop `` command stops the server listening
103
+ on port 8000 on the loopback device.
104
+
105
+ Monitoring the Server Status
106
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
107
+
108
+ You can check status of the web server for a particular socket using the ``server:status ``
109
+ command (127.0.0.1:8000 being the default socket again):
110
+
111
+ .. code-block :: bash
112
+
113
+ $ php app/console server:status 127.0.0.1:8080
114
+
115
+ .. caution ::
116
+
117
+ The information shown by the ``server:status `` command would not be reliable
118
+ if you didn't terminate the server using the ``server:stop `` command (by
119
+ using the UNIX ``kill `` command or the Windows task manager, for example).
120
+
121
+ .. _`built-in web server` : http://www.php.net/manual/en/features.commandline.webserver.php
0 commit comments