Skip to content

Commit

Permalink
Merge branch '2.3' into 2.5
Browse files Browse the repository at this point in the history
* 2.3:
  Fixing bad `@AcmeHello` -> `@AcmeHelloBundle`
  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
  • Loading branch information
weaverryan committed Jan 25, 2015
2 parents 33914c9 + dc87147 commit 2f8a60e
Show file tree
Hide file tree
Showing 37 changed files with 291 additions and 212 deletions.
8 changes: 4 additions & 4 deletions best_practices/business-logic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ your app that's not specific to the framework (e.g. routing and controllers).
Domain classes, Doctrine entities and regular PHP classes that are used as
services are good examples of business logic.

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

.. code-block:: text
Expand Down Expand Up @@ -45,7 +45,7 @@ and put things there:
.. tip::

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

Expand Down Expand Up @@ -166,8 +166,8 @@ library or strategy you want for this.

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

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

Expand Down
4 changes: 2 additions & 2 deletions best_practices/controllers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ into a service.

.. best-practice::

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

Coupling the controllers to the underlying framework allows you to leverage
all of its features and increases your productivity.
Expand Down
22 changes: 11 additions & 11 deletions best_practices/creating-the-project.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,26 +109,26 @@ Application Bundles

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

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

.. best-practice::

Create only one bundle called ``AppBundle`` for your application logic
Create only one bundle called AppBundle for your application logic

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

.. note::

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

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

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

.. code-block:: bash
Expand Down
10 changes: 5 additions & 5 deletions book/controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,9 @@ Simple, right?
Route Parameters as Controller Arguments
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

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

Expand Down
30 changes: 19 additions & 11 deletions book/doctrine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ information. By convention, this information is usually configured in an
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine
http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
<doctrine:config>
<doctrine:dbal
Expand Down Expand Up @@ -165,8 +167,10 @@ for you:
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine
http://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
<doctrine:config>
<doctrine:dbal
Expand All @@ -193,7 +197,7 @@ Creating an Entity Class
Suppose you're building an application where products need to be displayed.
Without even thinking about Doctrine or databases, you already know that
you need a ``Product`` object to represent those products. Create this class
inside the ``Entity`` directory of your ``AppBundle``::
inside the ``Entity`` directory of your AppBundle::

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

$em = $this->getDoctrine()->getManager();
$products = $em->getRepository('AppBundle:Product')
->findAllOrderedByName();
->findAllOrderedByName();

.. note::

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

.. code-block:: bash
$ php app/console doctrine:generate:entity --entity="AppBundle:Category" --fields="name:string(255)"
$ php app/console doctrine:generate:entity \
--entity="AppBundle:Category" \
--fields="name:string(255)"
This task generates the ``Category`` entity for you, with an ``id`` field,
a ``name`` field and the associated getter and setter functions.
Expand Down Expand Up @@ -929,7 +936,8 @@ To relate the ``Category`` and ``Product`` entities, start by creating a
products:
targetEntity: Product
mappedBy: category
# don't forget to init the collection in the __construct() method of the entity
# don't forget to init the collection in the __construct() method
# of the entity
.. code-block:: xml
Expand Down Expand Up @@ -1038,7 +1046,7 @@ methods for you:

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

You can also query in the other direction::

public function showProductAction($id)
public function showProductsAction($id)
{
$category = $this->getDoctrine()
->getRepository('AppBundle:Category')
Expand Down Expand Up @@ -1372,7 +1380,7 @@ list of all available types and more information, see Doctrine's
Summary
-------

With Doctrine, you can focus on your objects and how they're useful in your
With Doctrine, you can focus on your objects and how they're used in your
application and worry about database persistence second. This is because
Doctrine allows you to use any PHP object to hold your data and relies on
mapping metadata information to map an object's data to a particular database
Expand Down
19 changes: 13 additions & 6 deletions book/http_cache.rst
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ If one content corresponds to one URL, the ``PURGE`` model works well.
You send a request to the cache proxy with the HTTP method ``PURGE`` (using
the word "PURGE" is a convention, technically this can be any string) instead
of ``GET`` and make the cache proxy detect this and remove the data from the
cache instead of going to Symfony to get a response.
cache instead of going to the application to get a response.

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

if ('127.0.0.1' !== $request->getClientIp()) {
return new Response('Invalid HTTP method', Response::HTTP_BAD_REQUEST);
return new Response(
'Invalid HTTP method',
Response::HTTP_BAD_REQUEST
);
}

$response = new Response();
Expand Down Expand Up @@ -987,8 +990,10 @@ First, to use ESI, be sure to enable it in your application configuration:
<container xmlns="http://symfony.com/schema/dic/symfony"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:framework="http://symfony.com/schema/dic/symfony"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<framework:config>
<!-- ... -->
Expand Down Expand Up @@ -1115,8 +1120,10 @@ that must be enabled in your configuration:
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doctrine="http://symfony.com/schema/dic/framework"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
xsi:schemaLocation="http://symfony.com/schema/dic/services
http://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/symfony
http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
<!-- ... -->
<framework:config>
Expand Down
41 changes: 21 additions & 20 deletions book/page_creation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,12 @@ to a specific feature, including PHP classes, configuration, and even stylesheet
and JavaScript files (see :ref:`page-creation-bundles`).

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

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

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

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

.. configuration-block::

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

.. note::

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

// src/Acme/DemoBundle/Controller/RandomController.php
namespace Acme\DemoBundle\Controller;
Expand Down Expand Up @@ -388,7 +389,7 @@ location using the following convention.

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

In this case, ``AcmeDemoBundle`` is the bundle name, ``Random`` is the
In this case, AcmeDemoBundle is the bundle name, ``Random`` is the
controller, and ``index.html.twig`` the template:

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

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

To show you how simple the bundle system is, create a new bundle called
``AcmeTestBundle`` and enable it.
AcmeTestBundle and enable it.

.. tip::

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

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

.. tip::

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

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

And while it doesn't do anything yet, ``AcmeTestBundle`` is now ready to
be used.
And while it doesn't do anything yet, AcmeTestBundle is now ready to be used.

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

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

``Controller/``
Contains the controllers of the bundle (e.g. ``RandomController.php``).
Expand Down
Loading

0 comments on commit 2f8a60e

Please sign in to comment.