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