Skip to content

Commit 8b0c026

Browse files
committed
Merge branch '2.6' into 2.7
* 2.6: Adding one more note about why we're in config.yml [symfony#5302] Re-reading sections after moving them, and tweaking some things that did not make sense anymore Update doctrine.rst Place DQL in front of QueryBuilder Slight re-wording of new paragraph with the goal of being as short as possible Fix formatting error Created a new section for rotating log files and explained the max_files configuration option Fixes after review Changed comment from # to // Applied comments [BestPractices] restructured text format for the installation instructions template Better illustrate what the "user mistake" is. Fix typo Added new recipe on upgrading a major version Fix little title case mistake Created 'upgrade' cookbook section Added XML and PHP configuration samples Added a note about the rotating_file monolog handler Changing back to config.yml and fixing some code block mistakes thanks to Wouter Making the channel handler more useful by showing it on the prod environment
2 parents 49a2a27 + e9ef6a4 commit 8b0c026

17 files changed

+474
-249
lines changed

book/doctrine.rst

+44-39
Original file line numberDiff line numberDiff line change
@@ -722,27 +722,30 @@ instead of querying for rows on a table (e.g. ``product``).
722722
When querying in Doctrine, you have two options: writing pure Doctrine queries
723723
or using Doctrine's Query Builder.
724724

725-
Querying for Objects Using Doctrine's Query Builder
726-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
725+
Querying for Objects with DQL
726+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
727727

728728
Imagine that you want to query for products, but only return products that
729729
cost more than ``19.99``, ordered from cheapest to most expensive. You can use
730-
Doctrine's ``QueryBuilder`` for this::
730+
Doctrine's native SQL-like language called DQL to make a query for this::
731731

732-
$repository = $this->getDoctrine()
733-
->getRepository('AppBundle:Product');
734-
735-
$query = $repository->createQueryBuilder('p')
736-
->where('p.price > :price')
737-
->setParameter('price', '19.99')
738-
->orderBy('p.price', 'ASC')
739-
->getQuery();
732+
$em = $this->getDoctrine()->getManager();
733+
$query = $em->createQuery(
734+
'SELECT p
735+
FROM AppBundle:Product p
736+
WHERE p.price > :price
737+
ORDER BY p.price ASC'
738+
)->setParameter('price', '19.99');
740739

741740
$products = $query->getResult();
741+
// to get just one result:
742+
// $product = $query->setMaxResults(1)->getOneOrNullResult();
742743

743-
The ``QueryBuilder`` object contains every method necessary to build your
744-
query. By calling the ``getQuery()`` method, the query builder returns a
745-
normal ``Query`` object, which can be used to get the result of the query.
744+
If you're comfortable with SQL, then DQL should feel very natural. The biggest
745+
difference is that you need to think in terms of "objects" instead of rows
746+
in a database. For this reason, you select *from* the ``AppBundle:Product``
747+
*object* (an optional shortcut for ``AppBundle\Entity\Product``) and then
748+
alias it as ``p``.
746749

747750
.. tip::
748751

@@ -751,40 +754,42 @@ normal ``Query`` object, which can be used to get the result of the query.
751754
(``:price`` in the example above) as it prevents SQL injection attacks.
752755

753756
The ``getResult()`` method returns an array of results. To get only one
754-
result, you can use ``getSingleResult()`` (which throws an exception if there
755-
is no result) or ``getOneOrNullResult()``::
757+
result, you can use ``getOneOrNullResult()``::
756758

757-
$product = $query->getOneOrNullResult();
759+
$product = $query->setMaxResults(1)->getOneOrNullResult();
758760

759-
For more information on Doctrine's Query Builder, consult Doctrine's
760-
`Query Builder`_ documentation.
761+
The DQL syntax is incredibly powerful, allowing you to easily join between
762+
entities (the topic of :ref:`relations <book-doctrine-relations>` will be
763+
covered later), group, etc. For more information, see the official
764+
`Doctrine Query Language`_ documentation.
761765

762-
Querying for Objects with DQL
763-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
766+
Querying for Objects Using Doctrine's Query Builder
767+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
764768

765-
Instead of using the ``QueryBuilder``, you can alternatively write the queries
766-
directly using DQL::
769+
Instead of writing a DQL string, you can alternatively use a helpful object called
770+
the ``QueryBuilder`` to build that string for you::
767771

768-
$em = $this->getDoctrine()->getManager();
769-
$query = $em->createQuery(
770-
'SELECT p
771-
FROM AppBundle:Product p
772-
WHERE p.price > :price
773-
ORDER BY p.price ASC'
774-
)->setParameter('price', '19.99');
772+
$repository = $this->getDoctrine()
773+
->getRepository('AppBundle:Product');
774+
775+
// createQueryBuilder automatically selects FROM AppBundle:Product
776+
// and aliases it to "p"
777+
$query = $repository->createQueryBuilder('p')
778+
->where('p.price > :price')
779+
->setParameter('price', '19.99')
780+
->orderBy('p.price', 'ASC')
781+
->getQuery();
775782

776783
$products = $query->getResult();
784+
// to get just one result:
785+
// $product = $query->setMaxResults(1)->getOneOrNullResult();
777786

778-
If you're comfortable with SQL, then DQL should feel very natural. The biggest
779-
difference is that you need to think in terms of "objects" instead of rows
780-
in a database. For this reason, you select *from* the ``AppBundle:Product``
781-
*object* and then alias it as ``p`` (as you see, this is equal to what you
782-
already did in the previous section).
787+
The ``QueryBuilder`` object contains every method necessary to build your
788+
query. By calling the ``getQuery()`` method, the query builder returns a
789+
normal ``Query`` object, which can be used to get the result of the query.
783790

784-
The DQL syntax is incredibly powerful, allowing you to easily join between
785-
entities (the topic of :ref:`relations <book-doctrine-relations>` will be
786-
covered later), group, etc. For more information, see the official
787-
`Doctrine Query Language`_ documentation.
791+
For more information on Doctrine's Query Builder, consult Doctrine's
792+
`Query Builder`_ documentation.
788793

789794
.. _book-doctrine-custom-repository-classes:
790795

components/options_resolver.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ the ``Mailer`` class makes a mistake?
9696
.. code-block:: php
9797
9898
$mailer = new Mailer(array(
99-
'usernme' => 'johndoe',
99+
'usernme' => 'johndoe', // usernAme misspelled
100100
));
101101
102102
No error will be shown. In the best case, the bug will appear during testing,

conf.py

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
# adding PhpLexer
2424
from sphinx.highlighting import lexers
2525
from pygments.lexers.compiled import CLexer
26+
from pygments.lexers.special import TextLexer
27+
from pygments.lexers.text import RstLexer
2628
from pygments.lexers.web import PhpLexer
2729

2830
# -- General configuration -----------------------------------------------------
@@ -97,14 +99,18 @@
9799
# -- Settings for symfony doc extension ---------------------------------------------------
98100

99101
# enable highlighting for PHP code not between ``<?php ... ?>`` by default
102+
lexers['markdown'] = TextLexer()
100103
lexers['php'] = PhpLexer(startinline=True)
101104
lexers['php-annotations'] = PhpLexer(startinline=True)
102105
lexers['php-standalone'] = PhpLexer(startinline=True)
103106
lexers['php-symfony'] = PhpLexer(startinline=True)
107+
lexers['rst'] = RstLexer()
104108
lexers['varnish3'] = CLexer()
105109
lexers['varnish4'] = CLexer()
106110

107111
config_block = {
112+
'markdown': 'Markdown',
113+
'rst': 'reStructuredText',
108114
'varnish3': 'Varnish 3',
109115
'varnish4': 'Varnish 4'
110116
}

contributing/code/bc.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Our backwards Compatibility Promise
1+
Our Backwards Compatibility Promise
22
===================================
33

44
Ensuring smooth upgrades of your projects is our first priority. That's why

cookbook/bundles/best_practices.rst

+81-31
Original file line numberDiff line numberDiff line change
@@ -209,52 +209,102 @@ Installation Instructions
209209
In order to ease the installation of third-party bundles, consider using the
210210
following standardized instructions in your ``README.md`` file.
211211

212-
.. code-block:: text
212+
.. configuration-block::
213213

214-
Installation
215-
============
214+
.. code-block:: markdown
216215
217-
Step 1: Download the Bundle
218-
---------------------------
216+
Installation
217+
============
219218
220-
Open a command console, enter your project directory and execute the
221-
following command to download the latest stable version of this bundle:
219+
Step 1: Download the Bundle
220+
---------------------------
222221
223-
```bash
224-
$ composer require <package-name> "~1"
225-
```
222+
Open a command console, enter your project directory and execute the
223+
following command to download the latest stable version of this bundle:
226224
227-
This command requires you to have Composer installed globally, as explained
228-
in the [installation chapter](https://getcomposer.org/doc/00-intro.md)
229-
of the Composer documentation.
225+
```bash
226+
$ composer require <package-name> "~1"
227+
```
230228
231-
Step 2: Enable the Bundle
232-
-------------------------
229+
This command requires you to have Composer installed globally, as explained
230+
in the [installation chapter](https://getcomposer.org/doc/00-intro.md)
231+
of the Composer documentation.
233232
234-
Then, enable the bundle by adding the following line in the `app/AppKernel.php`
235-
file of your project:
233+
Step 2: Enable the Bundle
234+
-------------------------
236235
237-
```php
238-
<?php
239-
// app/AppKernel.php
236+
Then, enable the bundle by adding the following line in the `app/AppKernel.php`
237+
file of your project:
240238
241-
// ...
242-
class AppKernel extends Kernel
243-
{
244-
public function registerBundles()
239+
```php
240+
<?php
241+
// app/AppKernel.php
242+
243+
// ...
244+
class AppKernel extends Kernel
245245
{
246-
$bundles = array(
247-
// ...
246+
public function registerBundles()
247+
{
248+
$bundles = array(
249+
// ...
250+
251+
new <vendor>\<bundle-name>\<bundle-long-name>(),
252+
);
248253
249-
new <vendor>\<bundle-name>\<bundle-long-name>(),
250-
);
254+
// ...
255+
}
251256
252257
// ...
253258
}
259+
```
254260
255-
// ...
256-
}
257-
```
261+
.. code-block:: rst
262+
263+
Installation
264+
============
265+
266+
Step 1: Download the Bundle
267+
---------------------------
268+
269+
Open a command console, enter your project directory and execute the
270+
following command to download the latest stable version of this bundle:
271+
272+
.. code-block:: bash
273+
274+
$ composer require <package-name> "~1"
275+
276+
This command requires you to have Composer installed globally, as explained
277+
in the `installation chapter`_ of the Composer documentation.
278+
279+
Step 2: Enable the Bundle
280+
-------------------------
281+
282+
Then, enable the bundle by adding the following line in the ``app/AppKernel.php``
283+
file of your project:
284+
285+
.. code-block:: php
286+
287+
<?php
288+
// app/AppKernel.php
289+
290+
// ...
291+
class AppKernel extends Kernel
292+
{
293+
public function registerBundles()
294+
{
295+
$bundles = array(
296+
// ...
297+
298+
new <vendor>\<bundle-name>\<bundle-long-name>(),
299+
);
300+
301+
// ...
302+
}
303+
304+
// ...
305+
}
306+
307+
.. _`installation chapter`: https://getcomposer.org/doc/00-intro.md
258308
259309
This template assumes that your bundle is in its ``1.x`` version. If not, change
260310
the ``"~1"`` installation version accordingly (``"~2"``, ``"~3"``, etc.)

cookbook/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The Cookbook
3030
symfony1
3131
templating/index
3232
testing/index
33-
upgrading
33+
upgrade/index
3434
validation/index
3535
web_server/index
3636
web_services/index

0 commit comments

Comments
 (0)