@@ -2,12 +2,14 @@ Symfony Local Web Server
2
2
========================
3
3
4
4
You can run Symfony applications with any web server (Apache, nginx, the
5
- internal PHP web server, etc.) However, Symfony provides its own web server to
6
- make you more productive while developing your apps .
5
+ internal PHP web server, etc.). However, Symfony provides its own web server to
6
+ make you more productive while developing your applications .
7
7
8
- This server is not intended for production use and it supports HTTP/2, TLS/SSL,
9
- automatic generation of security certificates, local domains, and many other
10
- features that sooner or later you'll need when developing web projects.
8
+ Although this server is not intended for production use, it supports HTTP/2,
9
+ TLS/SSL, automatic generation of security certificates, local domains, and many
10
+ other features that sooner or later you'll need when developing web projects.
11
+ Moreover, the server is not tied to Symfony and you can also use it with any
12
+ PHP application and even with HTML/SPA (single page applications).
11
13
12
14
Installation
13
15
------------
@@ -31,11 +33,11 @@ common workflow to serve a Symfony project:
31
33
[OK] Web server listening on http://127.0.0.1:....
32
34
...
33
35
34
- # Now, browse the given URL in your browser , or run this command:
36
+ # Now, browse the given URL, or run this command:
35
37
$ symfony open:local
36
38
37
39
Running the server this way makes it display the log messages in the console, so
38
- you can 't run other commands. If you prefer, you can run the Symfony server in
40
+ you won 't be able to run other commands at the same time . If you prefer, you can run the Symfony server in
39
41
the background:
40
42
41
43
.. code-block :: terminal
@@ -53,8 +55,8 @@ the background:
53
55
Enabling TLS
54
56
------------
55
57
56
- Browsing the secure version of your apps locally is important to early detect
57
- problems with mixed content and to run libraries that only run in HTTPS.
58
+ Browsing the secure version of your apps locally is important to detect
59
+ problems with mixed content early, and to run libraries that only run in HTTPS.
58
60
Traditionally this has been painful and complicated to set up, but the Symfony
59
61
server automates everything. First, run this command:
60
62
@@ -65,18 +67,20 @@ server automates everything. First, run this command:
65
67
This command creates a local certificate authority, registers it in your system
66
68
trust store, registers it in Firefox (this is required only for that browser)
67
69
and creates a default certificate for ``localhost `` and ``127.0.0.1 ``. In other
68
- words, it does everything for you. You can now browse your local app using
69
- HTTPS instead of HTTP.
70
+ words, it does everything for you.
71
+
72
+ Before browsing your local application with HTTPS instead of HTTP, restart its
73
+ server stopping and starting it again.
70
74
71
75
Different PHP Settings Per Project
72
76
----------------------------------
73
77
74
78
Selecting a Different PHP Version
75
79
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
76
80
77
- If you have multiple PHP versions installed in your computer, you can tell
81
+ If you have multiple PHP versions installed on your computer, you can tell
78
82
Symfony which one to use creating a file called ``.php-version `` at the project
79
- root dir :
83
+ root directory :
80
84
81
85
.. code-block :: terminal
82
86
@@ -88,8 +92,15 @@ root dir:
88
92
# use any PHP 7.x version available
89
93
$ echo "7" > .php-version
90
94
91
- This other command is useful if you don't remember all the PHP versions
92
- installed in your computer:
95
+ .. tip ::
96
+
97
+ The Symfony server traverses the directory structure up to the root
98
+ directory, so you can create a ``.php-version `` file in some parent
99
+ directory to set the same PHP version for a group of projects under that
100
+ directory.
101
+
102
+ This command is useful if you don't remember all the PHP versions installed on
103
+ your computer:
93
104
94
105
.. code-block :: terminal
95
106
@@ -98,8 +109,8 @@ installed in your computer:
98
109
Overriding PHP Config Options Per Project
99
110
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100
111
101
- You can change the value of any PHP runtime config option per project creating a
102
- file called ``php.ini `` at the project root dir . Add only the options you want
112
+ You can change the value of any PHP runtime config option per project by creating a
113
+ file called ``php.ini `` at the project root directory . Add only the options you want
103
114
to override:
104
115
105
116
.. code-block :: terminal
@@ -114,9 +125,11 @@ to override:
114
125
Running Commands with Different PHP Versions
115
126
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
116
127
117
- When running different PHP versions, it's useful to use the main ``symfony ``
118
- command as a wrapper of the ``php `` command to always select the most
119
- appropriate PHP version according to the project which is running the commands:
128
+ When running different PHP versions it's useful to use the main ``symfony ``
129
+ command as a wrapper for the ``php `` command. This allows you to always select
130
+ the most appropriate PHP version according to the project which is running the
131
+ commands. It also loads the env vars automatically, which is important when
132
+ running non-Symfony commands:
120
133
121
134
.. code-block :: terminal
122
135
@@ -139,13 +152,13 @@ to it:
139
152
Local Domain Names
140
153
------------------
141
154
142
- By default, projects are accessible at some random port of the ``12.7 .0.0.1 ``
143
- local IP. However, sometimes is preferable to associate a domain name to them:
155
+ By default, projects are accessible at some random port of the ``127 .0.0.1 ``
156
+ local IP. However, sometimes it is preferable to associate a domain name to them:
144
157
145
158
* It's more convenient when you work continuously on the same project because
146
159
port numbers can change but domains don't;
147
- * The behavior of some apps depend on their domains/subdomains;
148
- * To have stable endpoints, such as the local redirection URL of Oauth2.
160
+ * The behavior of some applications depend on their domains/subdomains;
161
+ * To have stable endpoints, such as the local redirection URL for Oauth2.
149
162
150
163
Setting up the Local Proxy
151
164
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -166,18 +179,18 @@ If this is the first time you run the proxy, you must follow these additional st
166
179
Defining the Local Domain
167
180
~~~~~~~~~~~~~~~~~~~~~~~~~
168
181
169
- By default, Symfony proposes ``.wip `` (for *Work in Progress *) as the local
170
- domains (but you can choose any other domain and TLD you like). Define a local
171
- domain for a project as follows:
182
+ By default, Symfony proposes ``.wip `` (for *Work in Progress *) for the local
183
+ domains (but you can choose any other TLD you like). Define a local domain for a
184
+ project as follows:
172
185
173
186
.. code-block :: terminal
174
187
175
188
$ cd my-project/
176
- $ symfony proxy:domain:attach my-domain.wip
189
+ $ symfony proxy:domain:attach my-domain
177
190
178
191
If you have installed the local proxy as explained in the previous section, you
179
- can now browse ``https://my-domain.wip `` to access to your local project with
180
- the new custom domain.
192
+ can now browse ``https://my-domain.wip `` to access your local project with the
193
+ new custom domain.
181
194
182
195
.. tip ::
183
196
@@ -194,9 +207,9 @@ domains work:
194
207
Long-Running Commands
195
208
---------------------
196
209
197
- Long-running commands, such as the ones related to compiling front-end web
198
- assets, block the terminal and you can't run other commands. The Symfony server
199
- provides a ``run `` command to wrap them as follows:
210
+ Long-running commands, such as the ones that compile front-end web assets, block
211
+ the terminal and you can't run other commands at the same time . The Symfony
212
+ server provides a ``run `` command to wrap them as follows:
200
213
201
214
.. code-block :: terminal
202
215
@@ -214,41 +227,42 @@ provides a ``run`` command to wrap them as follows:
214
227
Web server listening on ...
215
228
Command "yarn ..." running with PID ...
216
229
217
- # stop the command (and the whole server ) when you are finished
230
+ # stop the web server (and all the associated commands ) when you are finished
218
231
$ symfony server:stop
219
232
220
233
Bonus Features
221
234
--------------
222
235
223
- The Symfony server is much more than a local web server and it includes other
224
- useful features.
236
+ In addition to being a local web server, the Symfony server provides other
237
+ useful features:
225
238
226
239
Looking for Security Vulnerabilities
227
240
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
228
241
229
242
Instead of installing the :doc: `Symfony Security Checker </security/security_checker >`
230
- as a dependency of your projects, you can use this command from the Symfony server :
243
+ as a dependency of your projects, you can run the following command :
231
244
232
245
.. code-block :: terminal
233
246
234
247
$ symfony security:check
235
248
236
249
This command uses the same vulnerability database as the Symfony Security
237
- Checker but it also caches that information to keep checking security when
238
- it's not possible to access to that public database.
250
+ Checker but it does not make HTTP calls to the official API endpoint. Everything
251
+ (except cloning the public database) is done locally, which is the best for CI
252
+ (*continuous integration *) scenarios.
239
253
240
254
Creating Symfony Projects
241
255
~~~~~~~~~~~~~~~~~~~~~~~~~
242
256
243
- In addition to the `different ways to install Symfony `_, you can use this
244
- command from the Symfony server:
257
+ In addition to the `different ways of installing Symfony `_, you can use these
258
+ commands from the Symfony server:
245
259
246
260
.. code-block :: terminal
247
261
248
- # creates a new project based on the Symfony Skeleton
262
+ # creates a new project based on symfony/skeleton
249
263
$ symfony new my_project_name
250
264
251
- # creates a new project based on the Symfony Website Skeleton
265
+ # creates a new project based on symfony/website-skeleton
252
266
$ symfony new --full my_project_name
253
267
254
268
# creates a new project based on the Symfony Demo application
@@ -258,14 +272,14 @@ SymfonyCloud Integration
258
272
------------------------
259
273
260
274
The local Symfony server provides full, but optional, integration with
261
- `SymfonyCloud `_, a service optimized to run your Symfony apps on the cloud.
262
- It provides features such as creating environments, backups/snapshots, and
263
- even access to a copy of the production data in your local machine to help
264
- you debug any issues.
275
+ `SymfonyCloud `_, a service optimized to run your Symfony applications on the
276
+ cloud. It provides features such as creating environments, backups/snapshots,
277
+ and even access to a copy of the production data from your local machine to help
278
+ debug any issues.
265
279
266
280
`Read SymfonyCloud technical docs `_.
267
281
268
282
.. _`symfony.com/download` : https://symfony.com/download
269
- .. _`different ways to install Symfony` : https://symfony.com/download
283
+ .. _`different ways of installing Symfony` : https://symfony.com/download
270
284
.. _`SymfonyCloud` : https://symfony.com/cloud/
271
285
.. _`Read SymfonyCloud technical docs` : https://symfony.com/doc/master/cloud/intro.html
0 commit comments