28
28
Linux and Mac OS X Systems
29
29
~~~~~~~~~~~~~~~~~~~~~~~~~~
30
30
31
- Open your command console and execute the following commands::
31
+ Open your command console and execute the following commands:
32
32
33
33
.. code-block :: bash
34
34
@@ -40,14 +40,14 @@ This will create a global ``symfony`` command in your system.
40
40
Windows Systems
41
41
~~~~~~~~~~~~~~~
42
42
43
- Open your command console and execute the following command::
43
+ Open your command console and execute the following command:
44
44
45
45
.. code-block :: bash
46
46
47
47
c:\> php -r " readfile('https://symfony.com/installer');" > symfony
48
48
49
49
Then, move the downloaded ``symfony `` file to your project's directory and
50
- execute it as follows::
50
+ execute it as follows:
51
51
52
52
.. code-block :: bash
53
53
@@ -60,7 +60,7 @@ Creating the Symfony Application
60
60
--------------------------------
61
61
62
62
Once the Symfony Installer is available, create your first Symfony application
63
- with the ``new `` command::
63
+ with the ``new `` command:
64
64
65
65
.. code-block :: bash
66
66
@@ -92,7 +92,7 @@ Basing your Project on a Specific Symfony Version
92
92
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93
93
94
94
In case your project needs to be based on a specific Symfony version, use the
95
- optional second argument of the ``new `` command::
95
+ optional second argument of the ``new `` command:
96
96
97
97
.. code-block :: bash
98
98
@@ -109,7 +109,7 @@ optional second argument of the ``new`` command::
109
109
$ symfony new my_project 2.7.0-RC1
110
110
111
111
The installer also supports a special version called ``lts `` which installs the
112
- most recent :ref: `Symfony LTS version <releases-lts >` available::
112
+ most recent :ref: `Symfony LTS version <releases-lts >` available:
113
113
114
114
.. code-block :: bash
115
115
@@ -141,14 +141,14 @@ Creating a Symfony Application with Composer
141
141
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
142
142
143
143
Once Composer is installed on your computer, execute the ``create-project `` Composer
144
- command to create a new Symfony application based on its latest stable version::
144
+ command to create a new Symfony application based on its latest stable version:
145
145
146
146
.. code-block :: bash
147
147
148
148
$ composer create-project symfony/framework-standard-edition my_project_name
149
149
150
150
If you need to base your application on a specific Symfony version, provide that
151
- version as the second argument of the ``create-project `` Composer command::
151
+ version as the second argument of the ``create-project `` Composer command:
152
152
153
153
.. code-block :: bash
154
154
@@ -160,14 +160,12 @@ version as the second argument of the ``create-project`` Composer command::
160
160
doing anything. If that's your case, add the ``-vvv `` flag to the previous
161
161
command to display a detailed output of everything that Composer is doing.
162
162
163
- $ composer create-project -vvv symfony/framework-standard-edition my_project_name "2.3.*"
164
-
165
163
Running the Symfony Application
166
164
-------------------------------
167
165
168
166
Symfony leverages the internal web server provided by PHP to run applications
169
167
while developing them. Therefore, running a Symfony application is a matter of
170
- browsing the project directory and executing this command::
168
+ browsing the project directory and executing this command:
171
169
172
170
.. code-block :: bash
173
171
@@ -187,16 +185,12 @@ possible solutions depending on your operating system. All of them are
187
185
explained in the :ref: `Setting up Permissions <book-installation-permissions >`
188
186
section of this chapter.
189
187
190
- Using PHP's internal web server is only suitable while developing the application.
191
- In order to run Symfony applications on production servers, you'll have to
192
- configure your `Apache `_ or `Nginx `_ web server and virtual host as explained in
193
- cookbook article :doc: `/cookbook/configuration/web_server_configuration `.
188
+ PHP's internal web server is great for developing, but should **not ** be used on
189
+ production. Instead, use Apache or Nginx. See :doc: `/cookbook/configuration/web_server_configuration `.
194
190
195
191
.. note ::
196
192
197
- PHP's internal web server is available in PHP 5.4 or higher versions. So, if you
198
- still use the legacy PHP 5.3 version, you'll also have to configure `Apache `_ or
199
- `Nginx `_ web server and virtual host.
193
+ PHP's internal web server is available in PHP 5.4 or higher versions.
200
194
201
195
When you are finished working on your Symfony application, you can stop the
202
196
server by pressing `Ctrl+C ` from terminal.
@@ -206,7 +200,7 @@ Checking Symfony Application Configuration and Setup
206
200
207
201
Symfony applications come with a visual server configuration tester to show if
208
202
your environment is ready to use Symfony. Access the following URL to check your
209
- configuration::
203
+ configuration:
210
204
211
205
.. code-block :: text
212
206
@@ -301,7 +295,7 @@ and they are managed exclusively by Composer.
301
295
302
296
Updating those third-party libraries frequently is a good practice to prevent bugs
303
297
and security vulnerabilities. Execute the ``update `` Composer command to update
304
- them all at once::
298
+ them all at once:
305
299
306
300
.. code-block :: bash
307
301
@@ -311,6 +305,18 @@ them all at once::
311
305
Depending on the complexity of your project, this update process can take up to
312
306
several minutes to complete.
313
307
308
+ .. tip ::
309
+
310
+ Symfony provides a command to check whether your project's dependencies
311
+ contain any known security vulnerability:
312
+
313
+ .. code-block :: bash
314
+
315
+ $ php app/console security:check
316
+
317
+ A good security practice is to execute this command regularly to be able to
318
+ update or replace compromised dependencies as soon as possible.
319
+
314
320
Installing the Symfony Demo Application
315
321
---------------------------------------
316
322
@@ -320,7 +326,7 @@ conceived as a learning tool for Symfony newcomers and its source code contains
320
326
tons of comments and helpful notes.
321
327
322
328
In order to download the Symfony Demo application, execute the ``demo `` command
323
- of the Symfony Installer anywhere in your system::
329
+ of the Symfony Installer anywhere in your system:
324
330
325
331
.. code-block :: bash
326
332
@@ -344,7 +350,7 @@ Symfony project packages "distributions", which are fully-functional application
344
350
that include the Symfony core libraries, a selection of useful bundles, a
345
351
sensible directory structure and some default configuration. In fact, when you
346
352
created a Symfony application in the previous sections, you actually downloaded the
347
- default distribution provided by Symfony, which is called * `Symfony Standard Edition`_ * .
353
+ default distribution provided by Symfony, which is called `Symfony Standard Edition `_.
348
354
349
355
The Symfony Standard Edition is by far the most popular distribution and it's
350
356
also the best choice for developers starting with Symfony. However, the Symfony
@@ -353,25 +359,43 @@ applications:
353
359
354
360
* The `Symfony CMF Standard Edition `_ is the best distribution to get started
355
361
with the `Symfony CMF `_ project, which is a project that makes it easier for
356
- developers to add ` CMS `_ functionality to applications built with the Symfony
362
+ developers to add CMS functionality to applications built with the Symfony
357
363
Framework.
358
364
* The `Symfony REST Edition `_ shows how to build an application that provides a
359
365
RESTful API using the `FOSRestBundle `_ and several other related bundles.
360
366
361
- Configuration Formats
362
- ---------------------
367
+ Using Source Control
368
+ --------------------
369
+
370
+ If you're using a version control system like `Git `_, you can safely commit all
371
+ your project's code. The reason is that Symfony applications already contain a
372
+ ``.gitignore `` file specially prepared for Symfony.
373
+
374
+ For specific instructions on how best to set up your project to be stored
375
+ in Git, see :doc: `/cookbook/workflow/new_project_git `.
376
+
377
+ Checking out a versioned Symfony Application
378
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
379
+
380
+ When using Composer to manage application's dependencies, it's recommended to
381
+ ignore the entire ``vendor/ `` directory before committing its code to the
382
+ repository. This means that when checking out a Symfony application from a Git
383
+ repository, there will be no ``vendor/ `` directory and the application won't
384
+ work out-of-the-box.
363
385
364
- Symfony supports several configuration formats: YAML, XML and PHP. Throughout
365
- the chapters, all configuration examples will be shown in all three formats.
366
- Each has its own advantages and disadvantages. The choice of which to use is up
367
- to you:
386
+ In order to make it work, check out the Symfony application and then execute the
387
+ ``install `` Composer command to download and install all the dependencies required
388
+ by the application:
368
389
369
- * *YAML *: Simple, clean and readable (learn more about YAML in the Yaml component
370
- documentation :doc: `/components/yaml/yaml_format `);
390
+ .. code-block :: bash
371
391
372
- * *XML *: More powerful than YAML at times and supports IDE autocompletion;
392
+ $ cd my_project_name/
393
+ $ composer install
373
394
374
- * *PHP *: Very powerful but less readable than standard configuration formats.
395
+ How does Composer know which specific dependencies to install? Because when a
396
+ Symfony application is committed to a repository, the ``composer.json `` and
397
+ ``composer.lock `` files are also committed. These files tell Composer which
398
+ dependencies (and which specific versions) to install for the application.
375
399
376
400
Beginning Development
377
401
---------------------
@@ -391,13 +415,10 @@ a wide variety of articles about solving specific problems with Symfony.
391
415
.. _`explained in this post` : http://fabien.potencier.org/signing-project-releases.html
392
416
.. _`Phar extension` : http://php.net/manual/en/intro.phar.php
393
417
.. _`Composer` : https://getcomposer.org/
394
- .. _`Apache` : http://httpd.apache.org/docs/current/mod/core.html#documentroot
395
- .. _`Nginx` : http://wiki.nginx.org/Symfony
396
418
.. _`enable ACL support` : https://help.ubuntu.com/community/FilePermissionsACLs
397
419
.. _`Git` : http://git-scm.com/
398
420
.. _`Symfony Standard Edition` : https://github.com/symfony/symfony-standard
399
421
.. _`Symfony CMF Standard Edition` : https://github.com/symfony-cmf/symfony-cmf-standard
400
422
.. _`Symfony CMF` : http://cmf.symfony.com/
401
- .. _`CMS` : https://en.wikipedia.org/wiki/Content_management_system
402
423
.. _`Symfony REST Edition` : https://github.com/gimler/symfony-rest-edition
403
424
.. _`FOSRestBundle` : https://github.com/FriendsOfSymfony/FOSRestBundle
0 commit comments