Skip to content

Commit 4d398c1

Browse files
committed
Merge branch '2.1'
2 parents ddf5c40 + e360b2c commit 4d398c1

File tree

9 files changed

+126
-79
lines changed

9 files changed

+126
-79
lines changed

book/from_flat_php_to_symfony2.rst

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -420,34 +420,36 @@ Why should you have to reinvent solutions to all these routine problems?
420420
Add a Touch of Symfony2
421421
~~~~~~~~~~~~~~~~~~~~~~~
422422

423-
Symfony2 to the rescue. Before actually using Symfony2, you need to make
424-
sure PHP knows how to find the Symfony2 classes. This is accomplished via
425-
an autoloader that Symfony provides. An autoloader is a tool that makes it
426-
possible to start using PHP classes without explicitly including the file
427-
containing the class.
423+
Symfony2 to the rescue. Before actually using Symfony2, you need to download
424+
it. This can be done by using Composer, which takes care of downloading the
425+
correct version and all its dependencies and provides an autoloader. An
426+
autoloader is a tool that makes it possible to start using PHP classes
427+
without explicitly including the file containing the class.
428428

429-
First, `download Symfony`_ and place it into a ``vendor/symfony/symfony/`` directory.
430-
Next, create an ``app/bootstrap.php`` file. Use it to ``require`` the two
431-
files in the application and to configure the autoloader:
429+
In your root directory, create a ``composer.json`` file with the following
430+
content:
432431

433-
.. code-block:: html+php
432+
.. code-block:: json
434433
435-
<?php
436-
// bootstrap.php
437-
require_once 'model.php';
438-
require_once 'controllers.php';
439-
require_once 'vendor/symfony/symfony/src/Symfony/Component/ClassLoader/UniversalClassLoader.php';
434+
{
435+
"require": {
436+
"symfony/symfony": "2.1.*"
437+
},
438+
"autoload": {
439+
"files": ["model.php","controller.php"]
440+
}
441+
}
442+
443+
Next, `download Composer`_ and then run the following command, which will download Symfony
444+
into a vendor/ directory:
440445

441-
$loader = new Symfony\Component\ClassLoader\UniversalClassLoader();
442-
$loader->registerNamespaces(array(
443-
'Symfony' => __DIR__.'/../vendor/symfony/symfony/src',
444-
));
446+
.. code-block:: bash
445447
446-
$loader->register();
448+
$ php composer.phar install
447449
448-
This tells the autoloader where the ``Symfony`` classes are. With this, you
449-
can start using Symfony classes without using the ``require`` statement for
450-
the files that contain them.
450+
Beside downloading your dependencies, Composer generates a ``vendor/autoload.php`` file,
451+
which takes care of autoloading for all the files in the Symfony Framework as well as
452+
the files mentioned in the autoload section of your ``composer.json``.
451453

452454
Core to Symfony's philosophy is the idea that an application's main job is
453455
to interpret each request and return a response. To this end, Symfony2 provides
@@ -460,7 +462,7 @@ the HTTP response being returned. Use them to improve the blog:
460462

461463
<?php
462464
// index.php
463-
require_once 'app/bootstrap.php';
465+
require_once 'vendor/bootstrap.php';
464466

465467
use Symfony\Component\HttpFoundation\Request;
466468
use Symfony\Component\HttpFoundation\Response;
@@ -752,7 +754,7 @@ Learn more from the Cookbook
752754
* :doc:`/cookbook/controller/service`
753755

754756
.. _`Doctrine`: http://www.doctrine-project.org
755-
.. _`download Symfony`: http://symfony.com/download
757+
.. _`download Composer`: http://getcomposer.org/download/
756758
.. _`Routing`: https://github.com/symfony/Routing
757759
.. _`Templating`: https://github.com/symfony/Templating
758760
.. _`KnpBundles.com`: http://knpbundles.com/

book/http_fundamentals.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,9 @@ Almost all modern web apps do this - including apps like WordPress.
357357
Stay Organized
358358
~~~~~~~~~~~~~~
359359

360-
But inside your front controller, how do you know which page should
361-
be rendered and how can you render each in a sane way? One way or another, you'll need to
362-
check the incoming URI and execute different parts of your code depending
360+
Inside your front controller, you have to figure out which code should be
361+
executed and what the content to return should be. To figure this out, you'll
362+
need to check the incoming URI and execute different parts of your code depending
363363
on that value. This can get ugly quickly::
364364

365365
// index.php
@@ -504,7 +504,7 @@ regardless of how your project is developed. To name a few:
504504
the ``Request`` and ``Response`` classes, as well as other classes for handling
505505
sessions and file uploads;
506506

507-
* :doc:`Routing</components/routing>` - Powerful and fast routing system that
507+
* :doc:`Routing</components/routing/introduction>` - Powerful and fast routing system that
508508
allows you to map a specific URI (e.g. ``/contact``) to some information
509509
about how that request should be handled (e.g. execute the ``contactAction()``
510510
method);

book/internals.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ on top of the previous one.
2323

2424
Autoloading is not managed by the framework directly; it's done by using
2525
Composer's autoloader (``vendor/autoload.php``), which is included in
26-
the ``src/autoload.php`` file.
26+
the ``app/autoload.php`` file.
2727

2828
``HttpFoundation`` Component
2929
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

book/page_creation.rst

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -512,13 +512,13 @@ You'll learn more about each of these directories in later chapters.
512512

513513
.. sidebar:: Autoloading
514514

515-
When Symfony is loading, a special file - ``app/autoload.php`` - is included.
516-
This file is responsible for configuring the autoloader, which will autoload
517-
your application files from the ``src/`` directory and third-party libraries
518-
from the ``vendor/`` directory.
515+
When Symfony is loading, a special file - ``vendor/autoload.php`` - is
516+
included. This file is created by Composer and will autoload all
517+
application files living in the `src/` folder as well as all
518+
third-party libraries mentioned in the ``composer.json`` file.
519519

520520
Because of the autoloader, you never need to worry about using ``include``
521-
or ``require`` statements. Instead, Symfony2 uses the namespace of a class
521+
or ``require`` statements. Instead, Composer uses the namespace of a class
522522
to determine its location and automatically includes the file on your
523523
behalf the instant you need a class.
524524

@@ -533,11 +533,6 @@ You'll learn more about each of these directories in later chapters.
533533
Path:
534534
src/Acme/HelloBundle/Controller/HelloController.php
535535
536-
Typically, the only time you'll need to worry about the ``app/autoload.php``
537-
file is when you're including a new third-party library in the ``vendor/``
538-
directory. For more information on autoloading, see
539-
:doc:`How to autoload Classes</components/class_loader>`.
540-
541536
The Source (``src``) Directory
542537
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
543538

@@ -609,7 +604,6 @@ are used by your application (including the core Symfony bundles).
609604

610605
A bundle can live *anywhere* as long as it can be autoloaded (via the
611606
autoloader configured at ``app/autoload.php``).
612-
613607
Creating a Bundle
614608
~~~~~~~~~~~~~~~~~
615609

components/using_components.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ How to Install and Use the Symfony2 Components
66
==============================================
77

88
If you're starting a new project (or already have a project) that will use
9-
one or more components, the easiest way to integrate everything is with Composer.
9+
one or more components, the easiest way to integrate everything is with `Composer`_.
1010
Composer is smart enough to download the component(s) that you need and take
1111
care of autoloading so that you can begin using the libraries immediately.
1212

@@ -33,13 +33,15 @@ may also need to adjust the version (e.g. ``2.1.1`` or ``2.2.*``).
3333

3434
You can research the component names and versions at `packagist.org`_.
3535

36-
**3.** Download the vendor libraries and generate the ``vendor/autoload.php`` file:
36+
**3.** `Install composer`_ if you don't already have it present on your system:
37+
38+
**4.** Download the vendor libraries and generate the ``vendor/autoload.php`` file:
3739

3840
.. code-block:: bash
3941
4042
$ php composer.phar install
4143
42-
**4.** Write your code:
44+
**5.** Write your code:
4345

4446
Once Composer has downloaded the component(s), all you need to do is include
4547
the ``vendor/autoload.php`` file that was generated by Composer. This file
@@ -48,6 +50,7 @@ immediately::
4850

4951
// File: src/script.php
5052

53+
// update this to the path to the "vendor/" directory, relative to this file
5154
require_once '../vendor/autoload.php';
5255

5356
use Symfony\Component\Finder\Finder;
@@ -93,4 +96,6 @@ documentation to find out more about how to use it.
9396

9497
And have fun!
9598

99+
.. _Composer: http://getcomposer.org
100+
.. _Install composer: http://getcomposer.org/download/
96101
.. _packagist.org: https://packagist.org/

contributing/code/security.rst

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,75 @@
1+
Security Issues
2+
===============
3+
4+
This document explains how Symfony security issues are handled by the Symfony
5+
core team (Symfony being the code hosted on the main ``symfony/symfony`` `Git
6+
repository`_).
7+
18
Reporting a Security Issue
2-
==========================
9+
--------------------------
10+
11+
If you think that you have found a security issue in Symfony, don't use the
12+
mailing-list or the bug tracker and don't publish it publicly. Instead, all
13+
security issues must be sent to **security [at] symfony.com**. Emails sent to
14+
this address are forwarded to the Symfony core-team private mailing-list.
315

4-
Found a security issue in Symfony2? Don't use the mailing-list or the bug
5-
tracker. All security issues must be sent to **security [at]
6-
symfony-project.com** instead. Emails sent to this address are forwarded to
7-
the Symfony core-team private mailing-list.
16+
Resolving Process
17+
-----------------
818

919
For each report, we first try to confirm the vulnerability. When it is
1020
confirmed, the core-team works on a solution following these steps:
1121

1222
1. Send an acknowledgement to the reporter;
1323
2. Work on a patch;
14-
3. Write a post describing the vulnerability, the possible exploits, and how
15-
to patch/upgrade affected applications;
16-
4. Apply the patch to all maintained versions of Symfony;
17-
5. Publish the post on the official Symfony blog.
24+
3. Write a security announcement for the official Symfony `blog`_ about the
25+
vulnerability. This post should contain the following information:
26+
27+
* a title that always include the "Security release" string;
28+
* a description of the vulnerability;
29+
* the affected versions;
30+
* the possible exploits;
31+
* how to patch/upgrade/workaround affected applications;
32+
* credits.
33+
4. Send the patch and the announcement to the reporter for review;
34+
5. Apply the patch to all maintained versions of Symfony;
35+
6. Package new versions for all affected versions;
36+
7. Publish the post on the official Symfony `blog`_ (it must also be added to
37+
the "`Security Advisories`_" category);
38+
8. Update the security advisory list (see below).
39+
40+
.. note::
41+
42+
Releases that include security issues should not be done on Saturday or
43+
Sunday, except if the vulnerability has been publicly posted.
1844

1945
.. note::
2046

2147
While we are working on a patch, please do not reveal the issue publicly.
48+
49+
Security Advisories
50+
-------------------
51+
52+
This section indexes security vulnerabilities that were fixed in Symfony
53+
releases, starting from Symfony 1.0.0:
54+
55+
* November 29, 2012: `Security release: Symfony 2.0.19 and 2.1.4 <http://symfony.com/blog/security-release-symfony-2-0-19-and-2-1-4>`_
56+
* November 25, 2012: `Security release: symfony 1.4.20 released <http://symfony.com/blog/security-release-symfony-1-4-20-released>`_
57+
* August 28, 2012: `Security Release: Symfony 2.0.17 released <http://symfony.com/blog/security-release-symfony-2-0-17-released>`_
58+
* May 30, 2012: `Security Release: symfony 1.4.18 released <http://symfony.com/blog/security-release-symfony-1-4-18-released>`_
59+
* February 24, 2012: `Security Release: Symfony 2.0.11 released <http://symfony.com/blog/security-release-symfony-2-0-11-released>`_
60+
* November 16, 2011: `Security Release: Symfony 2.0.6 <http://symfony.com/blog/security-release-symfony-2-0-6>`_
61+
* March 21, 2011: `symfony 1.3.10 and 1.4.10: security releases <http://symfony.com/blog/symfony-1-3-10-and-1-4-10-security-releases>`_
62+
* June 29, 2010: `Security Release: symfony 1.3.6 and 1.4.6 <http://symfony.com/blog/security-release-symfony-1-3-6-and-1-4-6>`_
63+
* May 31, 2010: `symfony 1.3.5 and 1.4.5 <http://symfony.com/blog/symfony-1-3-5-and-1-4-5>`_
64+
* February 25, 2010: `Security Release: 1.2.12, 1.3.3 and 1.4.3 <http://symfony.com/blog/security-release-1-2-12-1-3-3-and-1-4-3>`_
65+
* February 13, 2010: `symfony 1.3.2 and 1.4.2 <http://symfony.com/blog/symfony-1-3-2-and-1-4-2>`_
66+
* April 27, 2009: `symfony 1.2.6: Security fix <http://symfony.com/blog/symfony-1-2-6-security-fix>`_
67+
* October 03, 2008: `symfony 1.1.4 released: Security fix <http://symfony.com/blog/symfony-1-1-4-released-security-fix>`_
68+
* May 14, 2008: `symfony 1.0.16 is out <http://symfony.com/blog/symfony-1-0-16-is-out>`_
69+
* April 01, 2008: `symfony 1.0.13 is out <http://symfony.com/blog/symfony-1-0-13-is-out>`_
70+
* March 21, 2008: `symfony 1.0.12 is (finally) out ! <http://symfony.com/blog/symfony-1-0-12-is-finally-out>`_
71+
* June 25, 2007: `symfony 1.0.5 released (security fix) <http://symfony.com/blog/symfony-1-0-5-released-security-fix>`_
72+
73+
.. _Git repository: https://github.com/symfony/symfony
74+
.. _blog: https://symfony.com/blog/
75+
.. _Security Advisories: http://symfony.com/blog/category/security-advisories

contributing/code/standards.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ Naming Conventions
108108

109109
* Use namespaces for all classes;
110110

111+
* Abstract classes are often prefixed with `Abstract`;
112+
111113
* Suffix interfaces with `Interface`;
112114

113115
* Use alphanumeric characters and underscores for file names;

contributing/community/releases.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ The Release Process
22
===================
33

44
This document explains the Symfony release process (Symfony being the code
5-
hosted on the main symfony/symfony `Git repository`_).
5+
hosted on the main ``symfony/symfony`` `Git repository`_).
66

77
Symfony manages its releases through a *time-based model*; a new Symfony
88
release comes out every *six months*: one in *May* and one in *November*.

cookbook/symfony1.rst

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ That array told symfony1 exactly which file contained each class. In the
114114
production environment, this caused you to need to clear the cache when classes
115115
were added or moved.
116116

117-
In Symfony2, a new class - ``UniversalClassLoader`` - handles this process.
117+
In Symfony2, a tool named `Composer`_ handles this process.
118118
The idea behind the autoloader is simple: the name of your class (including
119119
the namespace) must match up with the path to the file containing that class.
120120
Take the ``FrameworkExtraBundle`` from the Symfony2 Standard Edition as an
@@ -136,18 +136,7 @@ As you can see, the location of the file follows the namespace of the class.
136136
Specifically, the namespace, ``Sensio\Bundle\FrameworkExtraBundle``, spells out
137137
the directory that the file should live in
138138
(``vendor/sensio/framework-extra-bundle/Sensio/Bundle/FrameworkExtraBundle/``).
139-
This is because, in the ``app/autoload.php`` file, you'll configure Symfony to
140-
look for the ``Sensio`` namespace in the ``vendor/sensio`` directory:
141-
142-
.. code-block:: php
143-
144-
// app/autoload.php
145-
146-
// ...
147-
$loader->registerNamespaces(array(
148-
...,
149-
'Sensio' => __DIR__.'/../vendor/sensio/framework-extra-bundle',
150-
));
139+
Composer can then look for the file at this specific place and load it very fast.
151140

152141
If the file did *not* live at this exact location, you'd receive a
153142
``Class "Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle" does not exist.``
@@ -160,24 +149,24 @@ contains a different class). In order for a class to be autoloaded, you
160149
As mentioned before, for the autoloader to work, it needs to know that the
161150
``Sensio`` namespace lives in the ``vendor/bundles`` directory and that, for
162151
example, the ``Doctrine`` namespace lives in the ``vendor/doctrine/orm/lib/``
163-
directory. This mapping is entirely controlled by you via the
164-
``app/autoload.php`` file.
152+
directory. This mapping is entirely controlled by Composer. Each
153+
third-party library you load through composer has their settings defined
154+
and Composer takes care of everything for you.
155+
156+
For this to work, all third-party libraries used by your project must be
157+
defined in the ``composer.json`` file.
165158

166159
If you look at the ``HelloController`` from the Symfony2 Standard Edition you
167160
can see that it lives in the ``Acme\DemoBundle\Controller`` namespace. Yet, the
168-
``Acme`` namespace is not defined in the ``app/autoload.php``. By default you
169-
do not need to explicitly configure the location of bundles that live in the
170-
``src/`` directory. The ``UniversalClassLoader`` is configured to fallback to
171-
the ``src/`` directory using its ``registerNamespaceFallbacks`` method:
161+
``AcmeDemoBundle`` is not defined in your ``composer.json`` file. Nonetheless are
162+
the files autoloaded. This is because you can tell composer to autoload files
163+
from specific directories without defining a dependency:
172164

173-
.. code-block:: php
174-
175-
// app/autoload.php
165+
.. code-block:: yaml
176166
177-
// ...
178-
$loader->registerNamespaceFallbacks(array(
179-
__DIR__.'/../src',
180-
));
167+
"autoload": {
168+
"psr-0": { "": "src/" }
169+
}
181170
182171
Using the Console
183172
-----------------
@@ -312,3 +301,4 @@ primarily to configure objects that you can use. For more information, see
312301
the chapter titled ":doc:`/book/service_container`".
313302

314303
.. _`Symfony2 Standard`: https://github.com/symfony/symfony-standard
304+
.. _`Composer`: http://getcomposer.org

0 commit comments

Comments
 (0)