Skip to content

Commit 99e2996

Browse files
committed
Merge branch '2.7'
* 2.7: Fixing bad `@AcmeHello` -> `@AcmeHelloBundle` don't explain deprecated `getName()` method Removed literals for bundle names Remove horizontal scrollbar Update gmail.rst Update cloud.rst Update spool.rst Update environments.rst Update configuration_organization.rst Update error_pages.rst Update apply_to_option.rst Update asset_management.rst Update prepend_extension.rst Update configuration.rst Update translation.rst Update doctrine.rst Update testing.rst Update http_cache.rst Update security.rst Update inheritance.rst
2 parents c33b371 + 7c07a44 commit 99e2996

38 files changed

+299
-221
lines changed

best_practices/business-logic.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ your app that's not specific to the framework (e.g. routing and controllers).
1010
Domain classes, Doctrine entities and regular PHP classes that are used as
1111
services are good examples of business logic.
1212

13-
For most projects, you should store everything inside the ``AppBundle``.
13+
For most projects, you should store everything inside the AppBundle.
1414
Inside here, you can create whatever directories you want to organize things:
1515

1616
.. code-block:: text
@@ -45,7 +45,7 @@ and put things there:
4545
4646
.. tip::
4747

48-
The recommended approach of using the ``AppBundle`` directory is for
48+
The recommended approach of using the ``AppBundle/`` directory is for
4949
simplicity. If you're advanced enough to know what needs to live in
5050
a bundle and what can live outside of one, then feel free to do that.
5151

@@ -166,8 +166,8 @@ library or strategy you want for this.
166166

167167
In practice, many Symfony applications rely on the independent
168168
`Doctrine project`_ to define their model using entities and repositories.
169-
Just like with business logic, we recommend storing Doctrine entities in
170-
the ``AppBundle``
169+
Just like with business logic, we recommend storing Doctrine entities in the
170+
AppBundle.
171171

172172
The three entities defined by our sample blog application are a good example:
173173

best_practices/controllers.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ into a service.
1313

1414
.. best-practice::
1515

16-
Make your controller extend the ``FrameworkBundle`` base Controller and
17-
use annotations to configure routing, caching and security whenever possible.
16+
Make your controller extend the FrameworkBundle base controller and use
17+
annotations to configure routing, caching and security whenever possible.
1818

1919
Coupling the controllers to the underlying framework allows you to leverage
2020
all of its features and increases your productivity.

best_practices/creating-the-project.rst

+11-11
Original file line numberDiff line numberDiff line change
@@ -109,26 +109,26 @@ Application Bundles
109109

110110
When Symfony 2.0 was released, most developers naturally adopted the symfony
111111
1.x way of dividing applications into logical modules. That's why many Symfony
112-
apps use bundles to divide their code into logical features: ``UserBundle``,
113-
``ProductBundle``, ``InvoiceBundle``, etc.
112+
apps use bundles to divide their code into logical features: UserBundle,
113+
ProductBundle, InvoiceBundle, etc.
114114

115115
But a bundle is *meant* to be something that can be reused as a stand-alone
116-
piece of software. If ``UserBundle`` cannot be used *"as is"* in other Symfony
117-
apps, then it shouldn't be its own bundle. Moreover ``InvoiceBundle`` depends
118-
on ``ProductBundle``, then there's no advantage to having two separate bundles.
116+
piece of software. If UserBundle cannot be used *"as is"* in other Symfony
117+
apps, then it shouldn't be its own bundle. Moreover InvoiceBundle depends on
118+
ProductBundle, then there's no advantage to having two separate bundles.
119119

120120
.. best-practice::
121121

122-
Create only one bundle called ``AppBundle`` for your application logic
122+
Create only one bundle called AppBundle for your application logic
123123

124-
Implementing a single ``AppBundle`` bundle in your projects will make your code
124+
Implementing a single AppBundle bundle in your projects will make your code
125125
more concise and easier to understand. Starting in Symfony 2.6, the official
126-
Symfony documentation uses the ``AppBundle`` name.
126+
Symfony documentation uses the AppBundle name.
127127

128128
.. note::
129129

130-
There is no need to prefix the ``AppBundle`` with your own vendor (e.g.
131-
``AcmeAppBundle``), because this application bundle is never going to be
130+
There is no need to prefix the AppBundle with your own vendor (e.g.
131+
AcmeAppBundle), because this application bundle is never going to be
132132
shared.
133133

134134
All in all, this is the typical directory structure of a Symfony application
@@ -152,7 +152,7 @@ that follows these best practices:
152152
153153
.. tip::
154154

155-
If your Symfony installation doesn't come with a pre-generated ``AppBundle``,
155+
If your Symfony installation doesn't come with a pre-generated AppBundle,
156156
you can generate it by hand executing this command:
157157

158158
.. code-block:: bash

book/controller.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,9 @@ Simple, right?
228228
Route Parameters as Controller Arguments
229229
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
230230

231-
You already know that the route points to the ``HelloController::indexAction()`` method
232-
that lives inside ``AppBundle``. What's more interesting is the argument
233-
that is passed to that method::
231+
You already know that the route points to the
232+
``HelloController::indexAction()`` method that lives inside AppBundle. What's
233+
more interesting is the argument that is passed to that method::
234234

235235
// src/AppBundle/Controller/HelloController.php
236236
// ...
@@ -771,8 +771,8 @@ object that's returned from *that* controller::
771771
Notice that the ``forward()`` method uses a special string representation
772772
of the controller (see :ref:`controller-string-syntax`). In this case, the
773773
target controller function will be ``SomethingController::fancyAction()``
774-
inside the ``AppBundle``. The array passed to the method becomes the arguments
775-
on the resulting controller. This same idea is used when embedding controllers
774+
inside the AppBundle. The array passed to the method becomes the arguments on
775+
the resulting controller. This same idea is used when embedding controllers
776776
into templates (see :ref:`templating-embedding-controller`). The target
777777
controller method would look something like this::
778778

book/doctrine.rst

+19-11
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ information. By convention, this information is usually configured in an
7777
<container xmlns="http://symfony.com/schema/dic/services"
7878
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7979
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
80-
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
81-
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
80+
xsi:schemaLocation="http://symfony.com/schema/dic/services
81+
http://symfony.com/schema/dic/services/services-1.0.xsd
82+
http://symfony.com/schema/dic/doctrine
83+
http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
8284
8385
<doctrine:config>
8486
<doctrine:dbal
@@ -165,8 +167,10 @@ for you:
165167
<container xmlns="http://symfony.com/schema/dic/services"
166168
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
167169
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
168-
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
169-
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
170+
xsi:schemaLocation="http://symfony.com/schema/dic/services
171+
http://symfony.com/schema/dic/services/services-1.0.xsd
172+
http://symfony.com/schema/dic/doctrine
173+
http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
170174
171175
<doctrine:config>
172176
<doctrine:dbal
@@ -193,7 +197,7 @@ Creating an Entity Class
193197
Suppose you're building an application where products need to be displayed.
194198
Without even thinking about Doctrine or databases, you already know that
195199
you need a ``Product`` object to represent those products. Create this class
196-
inside the ``Entity`` directory of your ``AppBundle``::
200+
inside the ``Entity`` directory of your AppBundle::
197201

198202
// src/AppBundle/Entity/Product.php
199203
namespace AppBundle\Entity;
@@ -426,6 +430,7 @@ mapping information) of a bundle or an entire namespace:
426430
427431
# generates all entities in the AppBundle
428432
$ php app/console doctrine:generate:entities AppBundle
433+
429434
# generates all entities of bundles in the Acme namespace
430435
$ php app/console doctrine:generate:entities Acme
431436
@@ -864,7 +869,7 @@ You can use this new method just like the default finder methods of the reposito
864869

865870
$em = $this->getDoctrine()->getManager();
866871
$products = $em->getRepository('AppBundle:Product')
867-
->findAllOrderedByName();
872+
->findAllOrderedByName();
868873

869874
.. note::
870875

@@ -884,7 +889,9 @@ you can let Doctrine create the class for you.
884889

885890
.. code-block:: bash
886891
887-
$ php app/console doctrine:generate:entity --entity="AppBundle:Category" --fields="name:string(255)"
892+
$ php app/console doctrine:generate:entity \
893+
--entity="AppBundle:Category" \
894+
--fields="name:string(255)"
888895
889896
This task generates the ``Category`` entity for you, with an ``id`` field,
890897
a ``name`` field and the associated getter and setter functions.
@@ -929,7 +936,8 @@ To relate the ``Category`` and ``Product`` entities, start by creating a
929936
products:
930937
targetEntity: Product
931938
mappedBy: category
932-
# don't forget to init the collection in the __construct() method of the entity
939+
# don't forget to init the collection in the __construct() method
940+
# of the entity
933941
934942
.. code-block:: xml
935943
@@ -1038,7 +1046,7 @@ methods for you:
10381046

10391047
.. code-block:: bash
10401048
1041-
$ php app/console doctrine:generate:entities Acme
1049+
$ php app/console doctrine:generate:entities AppBundle
10421050
10431051
Ignore the Doctrine metadata for a moment. You now have two classes - ``Category``
10441052
and ``Product`` with a natural one-to-many relationship. The ``Category``
@@ -1151,7 +1159,7 @@ the category (i.e. it's "lazily loaded").
11511159

11521160
You can also query in the other direction::
11531161

1154-
public function showProductAction($id)
1162+
public function showProductsAction($id)
11551163
{
11561164
$category = $this->getDoctrine()
11571165
->getRepository('AppBundle:Category')
@@ -1372,7 +1380,7 @@ list of all available types and more information, see Doctrine's
13721380
Summary
13731381
-------
13741382

1375-
With Doctrine, you can focus on your objects and how they're useful in your
1383+
With Doctrine, you can focus on your objects and how they're used in your
13761384
application and worry about database persistence second. This is because
13771385
Doctrine allows you to use any PHP object to hold your data and relies on
13781386
mapping metadata information to map an object's data to a particular database

book/http_cache.rst

+13-6
Original file line numberDiff line numberDiff line change
@@ -856,7 +856,7 @@ If one content corresponds to one URL, the ``PURGE`` model works well.
856856
You send a request to the cache proxy with the HTTP method ``PURGE`` (using
857857
the word "PURGE" is a convention, technically this can be any string) instead
858858
of ``GET`` and make the cache proxy detect this and remove the data from the
859-
cache instead of going to Symfony to get a response.
859+
cache instead of going to the application to get a response.
860860

861861
Here is how you can configure the Symfony reverse proxy to support the
862862
``PURGE`` HTTP method::
@@ -877,7 +877,10 @@ Here is how you can configure the Symfony reverse proxy to support the
877877
}
878878

879879
if ('127.0.0.1' !== $request->getClientIp()) {
880-
return new Response('Invalid HTTP method', Response::HTTP_BAD_REQUEST);
880+
return new Response(
881+
'Invalid HTTP method',
882+
Response::HTTP_BAD_REQUEST
883+
);
881884
}
882885

883886
$response = new Response();
@@ -987,8 +990,10 @@ First, to use ESI, be sure to enable it in your application configuration:
987990
<container xmlns="http://symfony.com/schema/dic/symfony"
988991
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
989992
xmlns:framework="http://symfony.com/schema/dic/symfony"
990-
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
991-
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
993+
xsi:schemaLocation="http://symfony.com/schema/dic/services
994+
http://symfony.com/schema/dic/services/services-1.0.xsd
995+
http://symfony.com/schema/dic/symfony
996+
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
992997
993998
<framework:config>
994999
<!-- ... -->
@@ -1115,8 +1120,10 @@ that must be enabled in your configuration:
11151120
<container xmlns="http://symfony.com/schema/dic/services"
11161121
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
11171122
xmlns:doctrine="http://symfony.com/schema/dic/framework"
1118-
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
1119-
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
1123+
xsi:schemaLocation="http://symfony.com/schema/dic/services
1124+
http://symfony.com/schema/dic/services/services-1.0.xsd
1125+
http://symfony.com/schema/dic/symfony
1126+
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
11201127
11211128
<!-- ... -->
11221129
<framework:config>

book/page_creation.rst

+21-20
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ to a specific feature, including PHP classes, configuration, and even stylesheet
101101
and JavaScript files (see :ref:`page-creation-bundles`).
102102

103103
Depending on the way you installed Symfony, you may already have a bundle called
104-
``AcmeDemoBundle``. Browse the ``src/`` directory of your project and check
104+
AcmeDemoBundle. Browse the ``src/`` directory of your project and check
105105
if there is a ``DemoBundle/`` directory inside an ``Acme/`` directory. If those
106106
directories already exist, skip the rest of this section and go directly to
107107
create the route.
108108

109-
To create a bundle called ``AcmeDemoBundle`` (a play bundle that you'll
109+
To create a bundle called AcmeDemoBundle (a play bundle that you'll
110110
build in this chapter), run the following command and follow the on-screen
111111
instructions (use all the default options):
112112

@@ -140,8 +140,8 @@ By default, the routing configuration file in a Symfony application is
140140
located at ``app/config/routing.yml``. Like all configuration in Symfony,
141141
you can also choose to use XML or PHP out of the box to configure routes.
142142

143-
If you look at the main routing file, you'll see that Symfony already added
144-
an entry when you generated the ``AcmeDemoBundle``:
143+
If you look at the main routing file, you'll see that Symfony already added an
144+
entry when you generated the AcmeDemoBundle:
145145

146146
.. configuration-block::
147147

@@ -181,9 +181,10 @@ an entry when you generated the ``AcmeDemoBundle``:
181181
182182
This entry is pretty basic: it tells Symfony to load routing configuration
183183
from the ``Resources/config/routing.yml`` (``routing.xml`` or ``routing.php``
184-
in the XML and PHP code example respectively) file that lives inside the ``AcmeDemoBundle``.
185-
This means that you place routing configuration directly in ``app/config/routing.yml``
186-
or organize your routes throughout your application, and import them from here.
184+
in the XML and PHP code example respectively) file that lives inside the
185+
AcmeDemoBundle. This means that you place routing configuration directly in
186+
``app/config/routing.yml`` or organize your routes throughout your application,
187+
and import them from here.
187188

188189
.. note::
189190

@@ -255,7 +256,7 @@ that controller.
255256
The controller - ``AcmeDemoBundle:Random:index`` is the *logical* name of
256257
the controller, and it maps to the ``indexAction`` method of a PHP class
257258
called ``Acme\DemoBundle\Controller\RandomController``. Start by creating this
258-
file inside your ``AcmeDemoBundle``::
259+
file inside your AcmeDemoBundle::
259260

260261
// src/Acme/DemoBundle/Controller/RandomController.php
261262
namespace Acme\DemoBundle\Controller;
@@ -388,7 +389,7 @@ location using the following convention.
388389

389390
**/path/to/BundleName**/Resources/views/**ControllerName**/**TemplateName**
390391

391-
In this case, ``AcmeDemoBundle`` is the bundle name, ``Random`` is the
392+
In this case, AcmeDemoBundle is the bundle name, ``Random`` is the
392393
controller, and ``index.html.twig`` the template:
393394

394395
.. configuration-block::
@@ -636,7 +637,7 @@ in your application and to optimize them the way you want.
636637
to the organization and best practices of :doc:`bundles </cookbook/bundles/best_practices>`.
637638

638639
A bundle is simply a structured set of files within a directory that implement
639-
a single feature. You might create a ``BlogBundle``, a ``ForumBundle`` or
640+
a single feature. You might create a BlogBundle, a ForumBundle or
640641
a bundle for user management (many of these exist already as open source
641642
bundles). Each directory contains everything related to that feature, including
642643
PHP files, templates, stylesheets, JavaScripts, tests and anything else.
@@ -685,13 +686,13 @@ The Symfony Standard Edition comes with a handy task that creates a fully-functi
685686
bundle for you. Of course, creating a bundle by hand is pretty easy as well.
686687

687688
To show you how simple the bundle system is, create a new bundle called
688-
``AcmeTestBundle`` and enable it.
689+
AcmeTestBundle and enable it.
689690

690691
.. tip::
691692

692693
The ``Acme`` portion is just a dummy name that should be replaced by
693-
some "vendor" name that represents you or your organization (e.g. ``ABCTestBundle``
694-
for some company named ``ABC``).
694+
some "vendor" name that represents you or your organization (e.g.
695+
ABCTestBundle for some company named ``ABC``).
695696

696697
Start by creating a ``src/Acme/TestBundle/`` directory and adding a new file
697698
called ``AcmeTestBundle.php``::
@@ -707,9 +708,10 @@ called ``AcmeTestBundle.php``::
707708

708709
.. tip::
709710

710-
The name ``AcmeTestBundle`` follows the standard :ref:`Bundle naming conventions <bundles-naming-conventions>`.
711-
You could also choose to shorten the name of the bundle to simply ``TestBundle``
712-
by naming this class ``TestBundle`` (and naming the file ``TestBundle.php``).
711+
The name AcmeTestBundle follows the standard
712+
:ref:`Bundle naming conventions <bundles-naming-conventions>`. You could
713+
also choose to shorten the name of the bundle to simply TestBundle by naming
714+
this class TestBundle (and naming the file ``TestBundle.php``).
713715

714716
This empty class is the only piece you need to create the new bundle. Though
715717
commonly empty, this class is powerful and can be used to customize the behavior
@@ -730,8 +732,7 @@ Now that you've created the bundle, enable it via the ``AppKernel`` class::
730732
return $bundles;
731733
}
732734

733-
And while it doesn't do anything yet, ``AcmeTestBundle`` is now ready to
734-
be used.
735+
And while it doesn't do anything yet, AcmeTestBundle is now ready to be used.
735736

736737
And as easy as this is, Symfony also provides a command-line interface for
737738
generating a basic bundle skeleton:
@@ -755,8 +756,8 @@ Bundle Directory Structure
755756

756757
The directory structure of a bundle is simple and flexible. By default, the
757758
bundle system follows a set of conventions that help to keep code consistent
758-
between all Symfony bundles. Take a look at ``AcmeDemoBundle``, as it contains
759-
some of the most common elements of a bundle:
759+
between all Symfony bundles. Take a look at AcmeDemoBundle, as it contains some
760+
of the most common elements of a bundle:
760761

761762
``Controller/``
762763
Contains the controllers of the bundle (e.g. ``RandomController.php``).

0 commit comments

Comments
 (0)