Skip to content

Commit cc87822

Browse files
committed
Merge branch '2.8'
* 2.8: (122 commits) moving options below basic usage changing a few orders of sections - mostly to move overridden after the main options Rewrite note a bit fix capitalization tweak headline to be consistent with 2.6 [Contributing] [Standards] Added entry for identical comparison Wrap the table creation inside the class extending Command, so users know where the comes. They can use it as standalone when needed [Serializer] Array Denormalization [Cookbook][Assetic] complete a sentence Fixing "Undefined method" error on Symfony 2.7 [symfony#5293] Tweak to link to the article about parent bundles Minor tweak to remove FOSUserBundle example and replace with a link to the doc about this overriding 3rd party bundles Adjust line wrapping Add formatting for file and method names Update load_balancer_reverse_proxy.rst removing upgrading.rst - this has already been moved into several documents in its own section [symfony#5166] Minor tweaks Revert "Changed dump() to var_dump()" Changed dump() to var_dump() ...
2 parents 2d430dc + acff5b0 commit cc87822

File tree

86 files changed

+1070
-371
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+1070
-371
lines changed

best_practices/creating-the-project.rst

+5
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ Symfony documentation uses the AppBundle name.
110110
There is no need to prefix the AppBundle with your own vendor (e.g.
111111
AcmeAppBundle), because this application bundle is never going to be
112112
shared.
113+
114+
.. note::
115+
116+
Another reason to create a new bundle is when you're overriding something
117+
in a vendor's bundle (e.g. a controller). See :doc:`/cookbook/bundles/inheritance`.
113118

114119
All in all, this is the typical directory structure of a Symfony application
115120
that follows these best practices:

book/doctrine.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -1204,7 +1204,8 @@ to the given ``Category`` object via their ``category_id`` value.
12041204
$category = $product->getCategory();
12051205

12061206
// prints "Proxies\AppBundleEntityCategoryProxy"
1207-
echo get_class($category);
1207+
dump(get_class($category));
1208+
die();
12081209

12091210
This proxy object extends the true ``Category`` object, and looks and
12101211
acts exactly like it. The difference is that, by using a proxy object,

book/service_container.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,11 @@ The service container is built using a single configuration resource
276276
be imported from inside this file in one way or another. This gives you absolute
277277
flexibility over the services in your application.
278278

279-
External service configuration can be imported in two different ways. The
280-
first - and most common method - is via the ``imports`` directive. Later, you'll
281-
learn about the second method, which is the flexible and preferred method
282-
for importing service configuration from third-party bundles.
279+
External service configuration can be imported in two different ways. The first
280+
method, commonly used to import container configuration from the bundles you've
281+
created - is via the ``imports`` directive. The second method, although slightly more
282+
complex offers more flexibility and is commonly used to import third-party bundle
283+
configuration. Read on to learn more about both methods.
283284

284285
.. index::
285286
single: Service Container; Imports

book/translation.rst

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ wrapping each with a function capable of translating the text (or "message")
1212
into the language of the user::
1313

1414
// text will *always* print out in English
15-
echo 'Hello World';
15+
dump('Hello World');
16+
die();
1617

1718
// text can be translated into the end-user's language or
1819
// default to English
19-
echo $translator->trans('Hello World');
20+
dump($translator->trans('Hello World'));
21+
die();
2022

2123
.. note::
2224

components/class_loader/class_map_generator.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ method::
5050

5151
use Symfony\Component\ClassLoader\ClassMapGenerator;
5252

53-
print_r(ClassMapGenerator::createMap(__DIR__.'/library'));
53+
var_dump(ClassMapGenerator::createMap(__DIR__.'/library'));
5454

5555
Given the files and class from the table above, you should see an output like
5656
this:

components/console/console_arguments.rst

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Have a look at the following command that has three options::
1414

1515
use Symfony\Component\Console\Command\Command;
1616
use Symfony\Component\Console\Input\InputArgument;
17+
use Symfony\Component\Console\Input\InputDefinition;
1718
use Symfony\Component\Console\Input\InputInterface;
1819
use Symfony\Component\Console\Input\InputOption;
1920
use Symfony\Component\Console\Output\OutputInterface;

components/console/helpers/table.rst

+19-12
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,25 @@ To display a table, use :class:`Symfony\\Component\\Console\\Helper\\Table`,
2121
set the headers, set the rows and then render the table::
2222

2323
use Symfony\Component\Console\Helper\Table;
24-
25-
$table = new Table($output);
26-
$table
27-
->setHeaders(array('ISBN', 'Title', 'Author'))
28-
->setRows(array(
29-
array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'),
30-
array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'),
31-
array('960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'),
32-
array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'),
33-
))
34-
;
35-
$table->render();
24+
// ...
25+
26+
class SomeCommand extends Command
27+
{
28+
public function execute(InputInterface $input, OutputInterface $output)
29+
{
30+
$table = new Table($output);
31+
$table
32+
->setHeaders(array('ISBN', 'Title', 'Author'))
33+
->setRows(array(
34+
array('99921-58-10-7', 'Divine Comedy', 'Dante Alighieri'),
35+
array('9971-5-0210-0', 'A Tale of Two Cities', 'Charles Dickens'),
36+
array('960-425-059-0', 'The Lord of the Rings', 'J. R. R. Tolkien'),
37+
array('80-902734-1-6', 'And Then There Were None', 'Agatha Christie'),
38+
))
39+
;
40+
$table->render();
41+
}
42+
}
3643

3744
You can add a table separator anywhere in the output by passing an instance of
3845
:class:`Symfony\\Component\\Console\\Helper\\TableSeparator` as a row::

components/console/introduction.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ level of verbosity.
200200
It is possible to print a message in a command for only a specific verbosity
201201
level. For example::
202202

203-
if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
203+
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
204204
$output->writeln(...);
205205
}
206206

components/console/logger.rst

+2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ The association between the log level and the verbosity can be configured
8080
through the second parameter of the :class:`Symfony\\Component\\Console\\ConsoleLogger`
8181
constructor::
8282

83+
use Psr\Log\LogLevel;
8384
// ...
85+
8486
$verbosityLevelMap = array(
8587
LogLevel::NOTICE => OutputInterface::VERBOSITY_NORMAL,
8688
LogLevel::INFO => OutputInterface::VERBOSITY_NORMAL,

components/css_selector.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ equivalents::
5151

5252
use Symfony\Component\CssSelector\CssSelector;
5353

54-
print CssSelector::toXPath('div.item > h4 > a');
54+
var_dump(CssSelector::toXPath('div.item > h4 > a'));
5555

5656
This gives the following output:
5757

components/dependency_injection/advanced.rst

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
Advanced Container Configuration
55
================================
66

7+
.. _container-private-services:
8+
79
Marking Services as public / private
810
------------------------------------
911

components/dom_crawler.rst

+7-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ traverse easily::
4747
$crawler = new Crawler($html);
4848

4949
foreach ($crawler as $domElement) {
50-
print $domElement->nodeName;
50+
var_dump($domElement->nodeName);
5151
}
5252

5353
Specialized :class:`Symfony\\Component\\DomCrawler\\Link` and
@@ -301,6 +301,12 @@ and :phpclass:`DOMNode` objects:
301301

302302
The ``html`` method is new in Symfony 2.3.
303303

304+
.. caution::
305+
306+
Due to an issue in PHP, the ``html()`` method returns wrongly decoded HTML
307+
entities in PHP versions lower than 5.3.6 (for example, it returns ````
308+
instead of ``&bull;``).
309+
304310
Links
305311
~~~~~
306312

components/event_dispatcher/generic_event.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ the event arguments::
7575
);
7676
$dispatcher->dispatch('foo', $event);
7777

78-
echo $event['counter'];
78+
var_dump($event['counter']);
7979

8080
class FooListener
8181
{
@@ -96,7 +96,7 @@ Filtering data::
9696
$event = new GenericEvent($subject, array('data' => 'Foo'));
9797
$dispatcher->dispatch('foo', $event);
9898

99-
echo $event['data'];
99+
var_dump($event['data']);
100100

101101
class FooListener
102102
{
@@ -105,3 +105,4 @@ Filtering data::
105105
$event['data'] = strtolower($event['data']);
106106
}
107107
}
108+

components/event_dispatcher/introduction.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ dispatched, are passed as arguments to the listener::
638638
{
639639
public function myEventListener(Event $event, $eventName, EventDispatcherInterface $dispatcher)
640640
{
641-
echo $eventName;
641+
// ... do something with the event name
642642
}
643643
}
644644

components/expression_language/caching.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Both ``evaluate()`` and ``compile()`` can handle ``ParsedExpression`` and
5656
// the parse() method returns a ParsedExpression
5757
$expression = $language->parse('1 + 4', array());
5858

59-
echo $language->evaluate($expression); // prints 5
59+
var_dump($language->evaluate($expression)); // prints 5
6060

6161
.. code-block:: php
6262
@@ -68,7 +68,7 @@ Both ``evaluate()`` and ``compile()`` can handle ``ParsedExpression`` and
6868
serialize($language->parse('1 + 4', array()))
6969
);
7070
71-
echo $language->evaluate($expression); // prints 5
71+
var_dump($language->evaluate($expression)); // prints 5
7272
7373
.. _DoctrineBridge: https://github.com/symfony/DoctrineBridge
7474
.. _`doctrine cache library`: http://docs.doctrine-project.org/projects/doctrine-common/en/latest/reference/caching.html

components/expression_language/extending.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ This method has 3 arguments:
4444
return strtolower($str);
4545
});
4646
47-
echo $language->evaluate('lowercase("HELLO")');
47+
var_dump($language->evaluate('lowercase("HELLO")'));
4848
4949
This will print ``hello``. Both the **compiler** and **evaluator** are passed
5050
an ``arguments`` variable as their first argument, which is equal to the
@@ -126,3 +126,4 @@ or by using the second argument of the constructor::
126126
parent::__construct($parser, $providers);
127127
}
128128
}
129+

components/expression_language/introduction.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ The main class of the component is
6868

6969
$language = new ExpressionLanguage();
7070

71-
echo $language->evaluate('1 + 2'); // displays 3
71+
var_dump($language->evaluate('1 + 2')); // displays 3
7272

73-
echo $language->compile('1 + 2'); // displays (1 + 2)
73+
var_dump($language->compile('1 + 2')); // displays (1 + 2)
7474

7575
Expression Syntax
7676
-----------------
@@ -96,12 +96,12 @@ PHP type (including objects)::
9696
$apple = new Apple();
9797
$apple->variety = 'Honeycrisp';
9898

99-
echo $language->evaluate(
99+
var_dump($language->evaluate(
100100
'fruit.variety',
101101
array(
102102
'fruit' => $apple,
103103
)
104-
);
104+
));
105105

106106
This will print "Honeycrisp". For more information, see the :doc:`/components/expression_language/syntax`
107107
entry, especially :ref:`component-expression-objects` and :ref:`component-expression-arrays`.

components/expression_language/syntax.rst

+12-12
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ to JavaScript::
4242
$apple = new Apple();
4343
$apple->variety = 'Honeycrisp';
4444

45-
echo $language->evaluate(
45+
var_dump($language->evaluate(
4646
'fruit.variety',
4747
array(
4848
'fruit' => $apple,
4949
)
50-
);
50+
));
5151

5252
This will print out ``Honeycrisp``.
5353

@@ -72,12 +72,12 @@ JavaScript::
7272

7373
$robot = new Robot();
7474

75-
echo $language->evaluate(
75+
var_dump($language->evaluate(
7676
'robot.sayHi(3)',
7777
array(
7878
'robot' => $robot,
7979
)
80-
);
80+
));
8181

8282
This will print out ``Hi Hi Hi!``.
8383

@@ -93,9 +93,9 @@ constant::
9393

9494
define('DB_USER', 'root');
9595

96-
echo $language->evaluate(
96+
var_dump($language->evaluate(
9797
'constant("DB_USER")'
98-
);
98+
));
9999

100100
This will print out ``root``.
101101

@@ -114,12 +114,12 @@ array keys, similar to JavaScript::
114114

115115
$data = array('life' => 10, 'universe' => 10, 'everything' => 22);
116116

117-
echo $language->evaluate(
117+
var_dump($language->evaluate(
118118
'data["life"] + data["universe"] + data["everything"]',
119119
array(
120120
'data' => $data,
121121
)
122-
);
122+
));
123123

124124
This will print out ``42``.
125125

@@ -140,14 +140,14 @@ Arithmetic Operators
140140

141141
For example::
142142

143-
echo $language->evaluate(
143+
var_dump($language->evaluate(
144144
'life + universe + everything',
145145
array(
146146
'life' => 10,
147147
'universe' => 10,
148148
'everything' => 22,
149149
)
150-
);
150+
));
151151

152152
This will print out ``42``.
153153

@@ -230,13 +230,13 @@ String Operators
230230

231231
For example::
232232

233-
echo $language->evaluate(
233+
var_dump($language->evaluate(
234234
'firstName~" "~lastName',
235235
array(
236236
'firstName' => 'Arthur',
237237
'lastName' => 'Dent',
238238
)
239-
);
239+
));
240240

241241
This would print out ``Arthur Dent``.
242242

components/finder.rst

+7-9
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ directories::
3030
$finder->files()->in(__DIR__);
3131

3232
foreach ($finder as $file) {
33-
// Print the absolute path
34-
print $file->getRealpath()."\n";
33+
// Dump the absolute path
34+
var_dump($file->getRealpath());
3535

36-
// Print the relative path to the file, omitting the filename
37-
print $file->getRelativePath()."\n";
36+
// Dump the relative path to the file, omitting the filename
37+
var_dump($file->getRelativePath());
3838

39-
// Print the relative path to the file
40-
print $file->getRelativePathname()."\n";
39+
// Dump the relative path to the file
40+
var_dump($file->getRelativePathname());
4141
}
4242

4343
The ``$file`` is an instance of :class:`Symfony\\Component\\Finder\\SplFileInfo`
@@ -118,9 +118,7 @@ And it also works with user-defined streams::
118118
$finder = new Finder();
119119
$finder->name('photos*')->size('< 100K')->date('since 1 hour ago');
120120
foreach ($finder->in('s3://bucket-name') as $file) {
121-
// ... do something
122-
123-
print $file->getFilename()."\n";
121+
// ... do something with the file
124122
}
125123

126124
.. note::

components/form/introduction.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,9 @@ is created from the form factory.
396396
->add('dueDate', 'date')
397397
->getForm();
398398
399-
echo $twig->render('new.html.twig', array(
399+
var_dump($twig->render('new.html.twig', array(
400400
'form' => $form->createView(),
401-
));
401+
)));
402402
403403
.. code-block:: php-symfony
404404

0 commit comments

Comments
 (0)