Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7808918

Browse filesBrowse files
committed
Lots of minor fixes
1 parent 32f84db commit 7808918
Copy full SHA for 7808918

File tree

Expand file treeCollapse file tree

1 file changed

+62
-48
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+62
-48
lines changed

‎setup/symfony_server.rst

Copy file name to clipboardExpand all lines: setup/symfony_server.rst
+62-48Lines changed: 62 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ Symfony Local Web Server
22
========================
33

44
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.
77

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).
1113

1214
Installation
1315
------------
@@ -31,11 +33,11 @@ common workflow to serve a Symfony project:
3133
[OK] Web server listening on http://127.0.0.1:....
3234
...
3335
34-
# Now, browse the given URL in your browser, or run this command:
36+
# Now, browse the given URL, or run this command:
3537
$ symfony open:local
3638
3739
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
3941
the background:
4042

4143
.. code-block:: terminal
@@ -53,8 +55,8 @@ the background:
5355
Enabling TLS
5456
------------
5557

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.
5860
Traditionally this has been painful and complicated to set up, but the Symfony
5961
server automates everything. First, run this command:
6062

@@ -65,18 +67,20 @@ server automates everything. First, run this command:
6567
This command creates a local certificate authority, registers it in your system
6668
trust store, registers it in Firefox (this is required only for that browser)
6769
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.
7074

7175
Different PHP Settings Per Project
7276
----------------------------------
7377

7478
Selecting a Different PHP Version
7579
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7680

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
7882
Symfony which one to use creating a file called ``.php-version`` at the project
79-
root dir:
83+
root directory:
8084

8185
.. code-block:: terminal
8286
@@ -88,8 +92,15 @@ root dir:
8892
# use any PHP 7.x version available
8993
$ echo "7" > .php-version
9094
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:
93104

94105
.. code-block:: terminal
95106
@@ -98,8 +109,8 @@ installed in your computer:
98109
Overriding PHP Config Options Per Project
99110
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100111

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
103114
to override:
104115

105116
.. code-block:: terminal
@@ -114,9 +125,11 @@ to override:
114125
Running Commands with Different PHP Versions
115126
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
116127

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:
120133

121134
.. code-block:: terminal
122135
@@ -139,13 +152,13 @@ to it:
139152
Local Domain Names
140153
------------------
141154

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:
144157

145158
* It's more convenient when you work continuously on the same project because
146159
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.
149162

150163
Setting up the Local Proxy
151164
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -166,18 +179,18 @@ If this is the first time you run the proxy, you must follow these additional st
166179
Defining the Local Domain
167180
~~~~~~~~~~~~~~~~~~~~~~~~~
168181

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:
172185

173186
.. code-block:: terminal
174187
175188
$ cd my-project/
176-
$ symfony proxy:domain:attach my-domain.wip
189+
$ symfony proxy:domain:attach my-domain
177190
178191
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.
181194

182195
.. tip::
183196

@@ -194,9 +207,9 @@ domains work:
194207
Long-Running Commands
195208
---------------------
196209

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:
200213

201214
.. code-block:: terminal
202215
@@ -214,41 +227,42 @@ provides a ``run`` command to wrap them as follows:
214227
Web server listening on ...
215228
Command "yarn ..." running with PID ...
216229
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
218231
$ symfony server:stop
219232
220233
Bonus Features
221234
--------------
222235

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:
225238

226239
Looking for Security Vulnerabilities
227240
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
228241

229242
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:
231244

232245
.. code-block:: terminal
233246
234247
$ symfony security:check
235248
236249
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.
239253

240254
Creating Symfony Projects
241255
~~~~~~~~~~~~~~~~~~~~~~~~~
242256

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:
245259

246260
.. code-block:: terminal
247261
248-
# creates a new project based on the Symfony Skeleton
262+
# creates a new project based on symfony/skeleton
249263
$ symfony new my_project_name
250264
251-
# creates a new project based on the Symfony Website Skeleton
265+
# creates a new project based on symfony/website-skeleton
252266
$ symfony new --full my_project_name
253267
254268
# creates a new project based on the Symfony Demo application
@@ -258,14 +272,14 @@ SymfonyCloud Integration
258272
------------------------
259273

260274
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.
265279

266280
`Read SymfonyCloud technical docs`_.
267281

268282
.. _`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
270284
.. _`SymfonyCloud`: https://symfony.com/cloud/
271285
.. _`Read SymfonyCloud technical docs`: https://symfony.com/doc/master/cloud/intro.html

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.