Skip to content
Closed
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
817 commits
Select commit Hold shift + click to select a range
cba307c
Merge branch '2.7' into 2.8
weaverryan Apr 12, 2016
b7c70e6
Merge branch '2.8' into 3.0
weaverryan Apr 12, 2016
164db85
Merge branch '2.7' into 2.8
weaverryan Apr 12, 2016
ffb40b9
Merge branch '2.8' into 3.0
weaverryan Apr 12, 2016
f723ea5
Added ldap to the list of user providers
a-ast Apr 12, 2016
5ba5224
fix broken merge
xabbuh Apr 13, 2016
5726c9b
minor #6471 fix broken merge (xabbuh)
xabbuh Apr 13, 2016
a9c9865
Merge branch '2.8' into 3.0
xabbuh Apr 13, 2016
282602e
Merge branch '2.7' into 2.8
wouterj Apr 20, 2016
a77a4b5
[Form] Document CollectionType's `prototype_data`
kgilden Oct 24, 2014
472fcd6
[Form] defined default and added example CollectionType `prototype_da…
HeahDude Apr 9, 2016
323ebcc
feature #6450 [Form] added prototype_data option in CollectionType (k…
wouterj Apr 20, 2016
43804ba
Merge branch '2.8' into 3.0
wouterj Apr 20, 2016
3b1f19e
[#6450] Remove versionadded in 3.0
wouterj Apr 20, 2016
5439c7a
[#6450] Use a reference for the field option
wouterj Apr 18, 2016
61b4cdd
Merge branch '2.8' into 3.0
wouterj Apr 20, 2016
1bfe021
fix typo
tyx Apr 21, 2016
ee94747
Update http_kernel_httpkernel_class.rst
AchillesKal Apr 21, 2016
be082ec
minor #6509 Update http_kernel_httpkernel_class.rst (AchillesKal)
xabbuh Apr 24, 2016
1c3a7bd
minor #6507 fix typo (tyx)
xabbuh Apr 24, 2016
7898df7
feature #6465 Added ldap to the list of user providers (AAstakhov)
xabbuh Apr 24, 2016
1bc1406
[#6465] fix newline position
xabbuh Apr 24, 2016
fb7d583
Merge branch '2.7' into 2.8
xabbuh Apr 24, 2016
0fb9bb5
Merge branch '2.8' into 3.0
xabbuh Apr 24, 2016
bcd7024
Merge branch '2.7' into 2.8
weaverryan Apr 26, 2016
9b85a73
Merge branch '2.8' into 3.0
weaverryan Apr 26, 2016
a50c5a2
Merge branch '2.7' into 2.8
xabbuh Apr 30, 2016
bfd32d7
Merge branch '2.8' into 3.0
xabbuh Apr 30, 2016
54d84e4
[DependencyInjection] Unquote services FQCN in autowiring examples
chalasr May 3, 2016
50a8777
[DomCrawler] Removed references to CssSelector
aerialls May 5, 2016
c1f64b7
feature #6302 [Form] add `choice_translation_domain` option to date t…
wouterj May 5, 2016
9448b1b
[#6302] Avoid duplication the body text
wouterj May 5, 2016
e6da57b
Merge branch '2.7' into 2.8
wouterj May 5, 2016
afdd44f
Added april changelog
wouterj May 5, 2016
e010cad
Merge branch '2.8' into 3.0
wouterj May 5, 2016
a59f2d5
Added April changelog
wouterj May 5, 2016
2d8f2ec
Make ClockMock Tests\\ namespace matching less specific
teohhanhui May 9, 2016
8f0e5ed
remove 2.x versionadded directives
xabbuh May 9, 2016
ac8a4d4
merge choice_translation_domain files
xabbuh May 9, 2016
c375b2f
minor #6529 [DependencyInjection] Unquote services FQCN in autowiring…
xabbuh May 9, 2016
bd4bb34
drop AppBundle examples in components section
xabbuh May 9, 2016
c8a76e3
minor #6536 [DomCrawler] Removed references to CssSelector (aerialls)
xabbuh May 9, 2016
ad85015
Merge branch '2.7' into 2.8
xabbuh May 9, 2016
3891d6b
Merge branch '2.8' into 3.0
xabbuh May 9, 2016
bdddaab
[PhpUnitBridge] Add versionadded directive to clock mocking section
z38 May 12, 2016
a3518aa
minor #6549 drop AppBundle examples in components section (xabbuh)
wouterj May 13, 2016
6b7b057
Merge branch '2.7' into 2.8
wouterj May 13, 2016
98d8755
[#6564] Revert doc removal in 2.8
wouterj May 13, 2016
1d73868
minor #6563 [PhpUnitBridge] Add versionadded directive to clock mocki…
wouterj May 13, 2016
1479082
Fix build
wouterj May 13, 2016
1e79c1c
bug #6546 Make ClockMock Tests\\ namespace matching less specific (te…
wouterj May 13, 2016
b61bc12
minor #6547 remove 2.x versionadded directives (xabbuh)
wouterj May 13, 2016
1b8163e
minor #6548 merge choice_translation_domain files (xabbuh)
wouterj May 13, 2016
0b11ccb
Merge branch '2.7' into 2.8
xabbuh May 14, 2016
f8d5f44
Merge branch '2.8' into 3.0
xabbuh May 14, 2016
cc1e804
Merge branch '2.7' into 2.8
xabbuh May 15, 2016
d719139
Merge branch '2.8' into 3.0
xabbuh May 15, 2016
dc0397d
Fix typo
jdreesen May 15, 2016
f3d4687
minor #6570 Fix typo (jdreesen)
xabbuh May 16, 2016
54bc800
[Cookbook][Profiler] Remove mention of import/export
hason May 18, 2016
0fb7847
minor #6577 [Cookbook][Profiler] Remove mention of import/export (hason)
xabbuh May 19, 2016
9916abf
Merge branch '2.7' into 2.8
wouterj May 21, 2016
c4ebee2
Merge branch '2.8' into 3.0
wouterj May 21, 2016
daaa466
Merge branch '2.7' into 2.8
wouterj May 21, 2016
bbdaba0
Merge branch '2.8' into 3.0
wouterj May 21, 2016
f84a1eb
Allowed to return null for query_builder
JonEastman May 21, 2016
3f9cf0b
feature #6594 Allowed to return null for query_builder (JonEastman)
wouterj May 21, 2016
f64fe19
[#6594] Add versionadded directive and capitialize Closure
wouterj May 21, 2016
991a135
Fix version
wouterj May 21, 2016
3a7d782
Merge branch '2.7' into 2.8
wouterj May 21, 2016
f199923
Merge branch '2.8' into 3.0
wouterj May 21, 2016
33d6855
Remove 2.x versionadded directives
wouterj May 21, 2016
c196b09
Merge branch '2.7' into 2.8
wouterj May 21, 2016
a1f8c3a
Merge branch '2.8' into 3.0
wouterj May 21, 2016
8045693
feature #6378 refs #5898 Fix updates of testing.rst for 3.0 (guilliam…
wouterj May 21, 2016
14482e4
Fixed null description of query_builder option
HeahDude May 21, 2016
f817323
Merge branch '2.7' into 2.8
xabbuh May 21, 2016
dc03f45
Merge branch '2.8' into 3.0
xabbuh May 21, 2016
3d4ae1e
Removing all instances of choices_as_values in 3.0
weaverryan Apr 12, 2016
a74dddd
minor #6459 Remove choices as values in 3.0 (weaverryan)
weaverryan May 22, 2016
1a600cd
Merge branch '2.7' into 2.8
weaverryan May 22, 2016
2c10e1d
Merge branch '2.8' into 3.0
weaverryan May 22, 2016
305abb8
Added documentation for the Ldap component
csarrazi Mar 27, 2016
cae7a80
deprecated 'datettime' Form Type
dsmink May 23, 2016
d2958ad
bug #6608 deprecated 'datettime' Form Type (dsmink)
wouterj May 27, 2016
1e63c9e
Merge branch '2.7' into 2.8
wouterj May 27, 2016
436a6a1
Merge branch '2.8' into 3.0
wouterj May 27, 2016
d96ed74
feature #6402 [RFR] Documentation for the Ldap component (csarrazi)
xabbuh May 29, 2016
b5c09b3
Merge branch '2.7' into 2.8
xabbuh May 29, 2016
ad76b72
Merge branch '2.8' into 3.0
xabbuh May 29, 2016
96dbba8
remove versionadded directive for 2.x features
xabbuh May 29, 2016
8b2691a
minor #6624 remove versionadded directive for 2.x features (xabbuh)
xabbuh May 30, 2016
b612563
Deprecated usage of AsseticBundle removed from bundles.rst
May 22, 2016
0edf881
minor #6601 Deprecated usage of AsseticBundle removed from bundles.rs…
xabbuh May 30, 2016
1ec853b
Merge branch '2.8' into 3.0
xabbuh Jun 6, 2016
7adc43d
Merge branch '2.7' into 2.8
xabbuh Jun 6, 2016
24d1e88
Merge branch '2.8' into 3.0
xabbuh Jun 6, 2016
2e11e48
Merge branch '2.7' into 2.8
xabbuh Jun 7, 2016
9c8bff6
Merge branch '2.8' into 3.0
xabbuh Jun 7, 2016
75c545c
do not reference unused interface
xabbuh Jun 8, 2016
5038684
minor #6642 do not reference unused interface (xabbuh)
weaverryan Jun 10, 2016
ab85c07
Merge branch '2.7' into 2.8
wouterj Jun 11, 2016
5d6a763
Added May changelog
wouterj Jun 11, 2016
b8a2ebc
Merge branch '2.8' into 3.0
wouterj Jun 11, 2016
2d4f0b8
Added May changelog
wouterj Jun 11, 2016
fc89d0e
Merge branch '2.7' into 2.8
wouterj Jun 12, 2016
bfcafee
Merge branch '2.8' into 3.0
wouterj Jun 12, 2016
de5025d
minor #6599 Fixed null description of query_builder option (HeahDude)
wouterj Jun 20, 2016
94c0f45
[#6599] Make description a little bit more clear
wouterj Jun 20, 2016
01bd606
Merge branch '2.7' into 2.8
xabbuh Jun 20, 2016
cd4f538
Merge branch '2.8' into 3.0
xabbuh Jun 20, 2016
f70aaeb
Merge branch '2.7' into 2.8
wouterj Jun 21, 2016
cf21977
Merge branch '2.8' into 3.0
wouterj Jun 21, 2016
7dfa573
Merge branch '2.7' into 2.8
wouterj Jun 24, 2016
9008a37
Merge branch '2.8' into 3.0
wouterj Jun 24, 2016
107913d
Fix ldap security examples
jvasseur Jun 24, 2016
cedfdc4
Added an example for a different method of verbosity level usage.
smatyas Jun 28, 2016
ad3dbba
feature #6690 Added an example for a different method of verbosity le…
xabbuh Jun 30, 2016
de9607d
[#6690] add versionadded directive
xabbuh Jun 30, 2016
8314edd
[#6690] fix syntax error
xabbuh Jun 30, 2016
bc45515
minor #6680 Fix ldap security examples (jvasseur)
xabbuh Jun 30, 2016
1397bac
Add missing parameter
rodnaph Jun 28, 2016
7d3bd81
minor #6693 Add missing parameter (rodnaph)
xabbuh Jun 30, 2016
ae615ef
[Ldap] add versionadded directive
xabbuh Jun 30, 2016
9a8b380
Merge branch '2.7' into 2.8
xabbuh Jun 30, 2016
73f1d51
Merge branch '2.8' into 3.0
xabbuh Jun 30, 2016
67a7779
minor #6698 [Ldap] add versionadded directive (xabbuh)
wouterj Jul 1, 2016
3ecf34a
Merge branch '2.7' into 2.8
wouterj Jul 1, 2016
2dcecb3
Merge branch '2.8' into 3.0
wouterj Jul 1, 2016
29b80a9
Merge branch '2.7' into 2.8
wouterj Jul 2, 2016
2221df8
added June changelog
wouterj Jul 2, 2016
2d4ead6
Merge branch '2.8' into 3.0
wouterj Jul 2, 2016
cf5c046
Routes should be just imported, not mounted
OndraM May 25, 2016
2e2e2dd
bug #6708 Routes should be just imported, not mounted (OndraM)
wouterj Jul 4, 2016
0e1128c
Merge branch '2.7' into 2.8
wouterj Jul 4, 2016
61cb386
Merge branch '2.8' into 3.0
wouterj Jul 4, 2016
afa8e0e
UppercaseRot13Transformer wrong class name used
Jul 4, 2016
750c6f8
bug #6714 UppercaseRot13Transformer wrong class name used (jevgenijusr)
wouterj Jul 5, 2016
048b853
[#6714] Rename UppercaseRot13Transformer to UppercaseTransformer
wouterj Jul 5, 2016
892fcce
Removed empty `Notes on previous versions`
mickaelandrieu Jul 1, 2016
3d54076
minor #6702 Removed empty `Notes on previous versions` (mickaelandrieu)
wouterj Jul 5, 2016
e3db793
Merge branch '2.7' into 2.8
wouterj Jul 5, 2016
813fdc2
Merge branch '2.8' into 3.0
wouterj Jul 5, 2016
679ac48
Merge branch '2.7' into 2.8
wouterj Jul 8, 2016
bdd73a6
Merge branch '2.8' into 3.0
wouterj Jul 8, 2016
7a5e0d2
Removed Symfony 2 versionadded directives
wouterj Jul 8, 2016
f40bb61
Merge branch '2.7' into 2.8
wouterj Jul 8, 2016
29ed05a
Merge branch '2.8' into 3.0
wouterj Jul 8, 2016
2dc8c63
[] changes in the first four ch of the book
talitakz Feb 10, 2016
c56db5c
made some new changes, corrected mistakes, undo some foolish deletions
talitakz Feb 12, 2016
62f5153
colon corrections
talitakz Feb 12, 2016
49ec40f
typo fix in hyperlink
talitakz Feb 12, 2016
689c2fd
typo fix in hyperlink
talitakz Feb 12, 2016
09b28bc
changes according to comments after PR + some other typos
talitakz Mar 18, 2016
47ffb4e
[WIP] Reading through the changes
weaverryan Jul 10, 2016
1297c75
[WIP] More changes
weaverryan Jul 10, 2016
6ae19f0
[WIP] Removing multiple formats - it makes no sense here
weaverryan Jul 10, 2016
c390d8d
[WIP] More changes
weaverryan Jul 10, 2016
a527a43
[WIP] More changes
weaverryan Jul 10, 2016
7e9dc86
Final changes
weaverryan Jul 10, 2016
bafea9d
Fixing typo
weaverryan Jul 10, 2016
f67f675
Replacing missing link
weaverryan Jul 10, 2016
68da559
Removing old :term: stuff
weaverryan Jul 10, 2016
6680621
minor #6743 Finishing #6252 (Talita Kocjan Zager, weaverryan)
weaverryan Jul 10, 2016
b44620d
[Form] Ambiguous block prefixes render incorrectly
jonny-no1 Jun 2, 2016
fcb4233
Merge branch '2.7' into 2.8
weaverryan Jul 10, 2016
113cbbc
feature #6744 [Form] Ambiguous block prefixes render incorrectly (foa…
weaverryan Jul 10, 2016
fb11636
Merge branch '2.8' into 3.0
weaverryan Jul 10, 2016
b33e777
Merge branch '2.7' into 2.8
wouterj Jul 13, 2016
c210d5f
Moved new cookbook articles to the topics
wouterj Jul 13, 2016
ecc2ed5
Merge branch '2.7' into 2.8
wouterj Jul 13, 2016
7b37ebc
Fix build
wouterj Jul 13, 2016
dd001ad
Merge branch '2.7' into 2.8
wouterj Jul 13, 2016
504214b
Merge branch '2.7' into 2.8
wouterj Jul 13, 2016
1cfaa88
Merge branch '2.8' into 3.0
wouterj Jul 13, 2016
3bf884e
Fix wrong references
wouterj Jul 13, 2016
6a9e519
Merge branch '2.7' into 2.8
xabbuh Jul 13, 2016
f6992a8
Merge branch '2.7' into 2.8
weaverryan Jul 14, 2016
769526e
Fixing heading styles that I just messed up!
weaverryan Jul 14, 2016
77157d9
Merge branch '2.8' into 3.0
weaverryan Jul 14, 2016
19b1f9c
fixing app/console
weaverryan Jul 14, 2016
06e3263
Merge branch '2.7' into 2.8
weaverryan Jul 14, 2016
aa788ed
Merge branch '2.8' into 3.0
weaverryan Jul 14, 2016
11149f4
[KnpU] Making common 3.0 changes (e.g. app/console -> bin/console)
weaverryan Jul 14, 2016
eec1e2f
Bootstrapping property info doc
weaverryan Jul 14, 2016
8650dd8
minor #82 Bootstrapping property info doc (weaverryan)
javiereguiluz Jul 15, 2016
85e111c
Added missing references
javiereguiluz Jul 15, 2016
4ab050d
Merge branch '2.7' into 2.8
wouterj Jul 15, 2016
5ab32fe
Merge branch '2.8' into 3.0
wouterj Jul 15, 2016
005e6f3
Fix merge
wouterj Jul 15, 2016
8c3acbe
Merge branch '2.8' into 3.0
wouterj Jul 15, 2016
9d3bc79
Remove remaining versionadded directives
wouterj Jul 15, 2016
46c6326
Build errors
wouterj Jul 15, 2016
fcbe902
Merge branch '2.8' into 3.0
wouterj Jul 15, 2016
5e9d255
Merge branch '2.7' into 2.8
wouterj Jul 15, 2016
4715fa6
Merge branch '2.8' into 3.0
wouterj Jul 15, 2016
6a5fc7f
Merge branch '2.7' into 2.8
wouterj Jul 16, 2016
a27789d
Fix build
wouterj Jul 16, 2016
be33b86
Merge branch '2.8' into 3.0
wouterj Jul 16, 2016
d7d851d
Fix build
wouterj Jul 16, 2016
d39277e
Remove mentions of (cook)book
wouterj Jul 16, 2016
181157f
Merge branch '2.8' into 3.0
wouterj Jul 16, 2016
5cef790
Merge branch '2.7' into 2.8
xabbuh Jul 19, 2016
6656856
Merge branch '2.7' into 2.8
xabbuh Jul 19, 2016
54a145c
fix some issues after merging 2.7 into 2.8
xabbuh Jul 19, 2016
ffd7507
minor #107 fix bugs due to choosing the wrong base branch (xabbuh)
xabbuh Jul 20, 2016
cd5afd3
Merge branch '2.8' into 3.0
xabbuh Jul 20, 2016
b9ebf03
after merge fixes
xabbuh Jul 20, 2016
8ae23dc
minor #109 after merge fixes (xabbuh)
xabbuh Jul 20, 2016
3f2f7b3
Merge branch '2.8' into 3.0
xabbuh Jul 20, 2016
9fb9fa8
Merge remote-tracking branch 'mercury/2.8' into 2.8
xabbuh Jul 20, 2016
d782d83
Merge branch '2.7' into 2.8
xabbuh Jul 20, 2016
088955b
Merge remote-tracking branch 'mercury/3.0' into 3.0
xabbuh Jul 21, 2016
912bc74
Merge branch '2.8' into 3.0
xabbuh Jul 21, 2016
c395c74
Merge branch '2.7' into 2.8
xabbuh Jul 28, 2016
19cc445
Merge branch '2.8' into 3.0
xabbuh Jul 28, 2016
8d60d5c
fixed missing level in namespace
themasch Jul 21, 2016
c2c4bf8
bug #6761 fixed missing level in namespace (themasch)
weaverryan Aug 2, 2016
732bb33
Merge branch '2.7' into 2.8
weaverryan Aug 2, 2016
bbb72b4
Merge branch '2.8' into 3.0
weaverryan Aug 2, 2016
396cf06
update `cache` and `logs` folder locations
georgiana-gligor Aug 2, 2016
fa57021
minor #6825 update `cache` and `logs` folder locations (georgiana-gli…
wouterj Aug 4, 2016
21fcb72
custom error pages - Reference to security functions warning is no mo…
hvt Jul 27, 2016
e051e98
minor #6850 Remove outdated reference (hvt)
wouterj Aug 5, 2016
d6c8a2e
Merge branch '2.7' into 2.8
wouterj Aug 5, 2016
6e7a7cb
Merge branch '2.8' into 3.0
wouterj Aug 5, 2016
e7c865e
Merge branch '2.7' into 2.8
wouterj Aug 5, 2016
4a15c8d
Added July changelog
wouterj Aug 5, 2016
0a36579
Merge branch '2.8' into 3.0
wouterj Aug 5, 2016
3ff5a22
Added July changelog
wouterj Aug 5, 2016
c56d5d8
Merge branch '2.7' into 2.8
wouterj Aug 11, 2016
1a3614c
Merge branch '2.8' into 3.0
wouterj Aug 11, 2016
cf7a0ea
Add PropertyInfo Component Documentation
Dec 5, 2015
96b139b
Suggested Changes
zanbaldwin Jul 11, 2016
7b786af
Fix Incorrect Indent
zanbaldwin Jul 11, 2016
78ea4a5
Update PropertyAccess Component Path
zanbaldwin Aug 16, 2016
a0409d7
Update Reference to Service Container Tags
zanbaldwin Aug 16, 2016
f7dad82
Merge branch '2.7' into 2.8
wouterj Aug 17, 2016
3b9db1f
Merge branch '2.8' into 3.0
wouterj Aug 17, 2016
6d282e4
Fix typos
rendler-denis Aug 18, 2016
794563f
feature #5974 [PropertyInfo] Add Component Documentation (zanderbaldwin)
weaverryan Aug 20, 2016
bc00741
Merge branch '2.7' into 2.8
weaverryan Aug 20, 2016
a465d06
Merge branch '2.8' into 3.0
weaverryan Aug 20, 2016
0986e5e
Merge remote-tracking branch 'origin/3.0' into 3.0
weaverryan Aug 20, 2016
d63a2f2
minor #6887 [FormComponent] Fix typos (rendler-denis)
weaverryan Aug 21, 2016
2d5b420
Update custom_provider.rst
asandjivy Aug 19, 2016
f11f34b
bug #6892 Update custom_provider.rst (asandjivy)
weaverryan Aug 21, 2016
563bab8
Merge branch '2.7' into 2.8
weaverryan Aug 21, 2016
98e65bf
Merge branch '2.8' into 3.0
weaverryan Aug 21, 2016
28bd6b7
DumpFile() third argument is deprecated and doesn't exists anymore in…
mickaelandrieu Aug 22, 2016
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 110 additions & 80 deletions book/from_flat_php_to_symfony2.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
.. index::
single: Symfony versus Flat PHP

.. _symfony2-versus-flat-php:

Symfony versus Flat PHP
=======================

**Why is Symfony better than just opening up a file and writing flat PHP?**

If you've never used a PHP framework, aren't familiar with the MVC philosophy,
or just wonder what all the *hype* is around Symfony, this chapter is for
you. Instead of *telling* you that Symfony allows you to develop faster and
better software than with flat PHP, you'll see for yourself.
If you've never used a PHP framework, aren't familiar with the
`Model-View-Controller`_ (MVC) philosophy, or just wonder what all the *hype*
is around Symfony, this chapter is for you. Instead of *telling* you that
Symfony allows you to develop faster and better software than with flat PHP,
you'll see for yourself.

In this chapter, you'll write a simple application in flat PHP, and then
refactor it to be more organized. You'll travel through time, seeing the
Expand Down Expand Up @@ -98,11 +102,12 @@ the code that prepares the HTML "presentation"::
require 'templates/list.php';


The HTML code is now stored in a separate file (``templates/list.php``), which
The HTML code is now stored in a separate file ``templates/list.php``, which
is primarily an HTML file that uses a template-like PHP syntax:

.. code-block:: html+php

<!-- templates/list.php -->
<!DOCTYPE html>
<html>
<head>
Expand Down Expand Up @@ -179,6 +184,7 @@ of the application are isolated in a new file called ``model.php``::

The controller (``index.php``) is now very simple::

// index.php
require_once 'model.php';

$posts = get_all_posts();
Expand All @@ -197,7 +203,7 @@ offering various advantages and the opportunity to reuse almost everything
on different pages.

The only part of the code that *can't* be reused is the page layout. Fix
that by creating a new ``layout.php`` file:
that by creating a new ``templates/layout.php`` file:

.. code-block:: html+php

Expand All @@ -212,11 +218,12 @@ that by creating a new ``layout.php`` file:
</body>
</html>

The template (``templates/list.php``) can now be simplified to "extend"
the layout:
The template ``templates/list.php`` can now be simplified to "extend"
the ``templates/layout.php``:

.. code-block:: html+php

<!-- templates/list.php -->
<?php $title = 'List of Posts' ?>

<?php ob_start() ?>
Expand All @@ -237,8 +244,9 @@ the layout:
You now have a setup that will allow you to reuse the layout.
Unfortunately, to accomplish this, you're forced to use a few ugly
PHP functions (``ob_start()``, ``ob_get_clean()``) in the template. Symfony
uses a Templating component that allows this to be accomplished cleanly
and easily. You'll see it in action shortly.
uses a :doc:`Templating </components/templating/introduction>` component
that allows this to be accomplished cleanly and easily. You'll see it in
action shortly.

Adding a Blog "show" Page
-------------------------
Expand Down Expand Up @@ -270,6 +278,7 @@ an individual blog result based on a given id::
Next, create a new file called ``show.php`` - the controller for this new
page::

// show.php
require_once 'model.php';

$post = get_post_by_id($_GET['id']);
Expand All @@ -281,6 +290,7 @@ the individual blog post:

.. code-block:: html+php

<!-- templates/show.php -->
<?php $title = $post['title'] ?>

<?php ob_start() ?>
Expand Down Expand Up @@ -327,9 +337,9 @@ application change slightly, but start to become more flexible:
/index.php/show => Blog post show page (index.php executed)

.. tip::
The ``index.php`` portion of the URI can be removed if using Apache
rewrite rules (or equivalent). In that case, the resulting URI of the
blog show page would be simply ``/show``.

By using rewrite rules in your :doc:`web server configuration </cookbook/configuration/web_server_configuration>`,
the ``index.php`` won't be needed and you will have beautiful, clean URLs (e.g. ``/show``).

When using a front controller, a single PHP file (``index.php`` in this case)
renders *every* request. For the blog post show page, ``/index.php/show`` will
Expand Down Expand Up @@ -364,8 +374,9 @@ on the requested URI::
}

For organization, both controllers (formerly ``index.php`` and ``show.php``)
are now PHP functions and each has been moved into a separate file, ``controllers.php``::
are now PHP functions and each has been moved into a separate file named ``controllers.php``::

// controllers.php
function list_action()
{
$posts = get_all_posts();
Expand All @@ -382,7 +393,11 @@ As a front controller, ``index.php`` has taken on an entirely new role, one
that includes loading the core libraries and routing the application so that
one of the two controllers (the ``list_action()`` and ``show_action()``
functions) is called. In reality, the front controller is beginning to look and
act a lot like Symfony's mechanism for handling and routing requests.
act a lot like how Symfony handles and routes requests.

But but careful not to confuse the terms *front controller* and *controller*. Your
app will usually have just *one* front controller, which boots your code. You will
have *many* controller functions: one for each page.

.. tip::

Expand All @@ -393,8 +408,8 @@ act a lot like Symfony's mechanism for handling and routing requests.

By now, the application has evolved from a single PHP file into a structure
that is organized and allows for code reuse. You should be happier, but far
from satisfied. For example, the "routing" system is fickle, and wouldn't
recognize that the list page (``/index.php``) should be accessible also via ``/``
from satisfied. For example, the routing system is fickle, and wouldn't
recognize that the list page - ``/index.php`` - should be accessible also via ``/``
(if Apache rewrite rules were added). Also, instead of developing the blog,
a lot of time is being spent working on the "architecture" of the code (e.g.
routing, calling controllers, templates, etc.). More time will need to be
Expand All @@ -407,7 +422,7 @@ Add a Touch of Symfony
~~~~~~~~~~~~~~~~~~~~~~

Symfony to the rescue. Before actually using Symfony, you need to download
it. This can be done by using Composer, which takes care of downloading the
it. This can be done by using `Composer`_, which takes care of downloading the
correct version and all its dependencies and provides an autoloader. An
autoloader is a tool that makes it possible to start using PHP classes
without explicitly including the file containing the class.
Expand All @@ -427,7 +442,7 @@ content:
}

Next, `download Composer`_ and then run the following command, which will download Symfony
into a vendor/ directory:
into a ``vendor/`` directory:

.. code-block:: bash

Expand Down Expand Up @@ -501,7 +516,8 @@ incidentally, acts quite a bit like the Symfony templating engine::

By bringing in a small part of Symfony, the application is more flexible and
reliable. The ``Request`` provides a dependable way to access information
about the HTTP request. Specifically, the ``getPathInfo()`` method returns
about the HTTP request. Specifically, the
:method:`Symfony\\Component\\HttpFoundation\\Request::getPathInfo` method returns
a cleaned URI (always returning ``/show`` and never ``/index.php/show``).
So, even if the user goes to ``/index.php/show``, the application is intelligent
enough to route the request through ``show_action()``.
Expand All @@ -520,8 +536,10 @@ The blog has come a *long* way, but it still contains a lot of code for such
a simple application. Along the way, you've made a simple routing
system and a method using ``ob_start()`` and ``ob_get_clean()`` to render
templates. If, for some reason, you needed to continue building this "framework"
from scratch, you could at least use Symfony's standalone `Routing`_ and
`Templating`_ components, which already solve these problems.
from scratch, you could at least use Symfony's standalone
:doc:`Routing </components/routing/introduction>` and
:doc:`Templating </components/templating/introduction>` components, which already
solve these problems.

Instead of re-solving common problems, you can let Symfony take care of
them for you. Here's the same sample application, now built in Symfony::
Expand Down Expand Up @@ -559,10 +577,14 @@ them for you. Here's the same sample application, now built in Symfony::
}
}

The two controllers are still lightweight. Each uses the
Notice, both controller functions now live inside a "controller class". This is a
nice way to group related pages. The controller functions are also sometimes called
*actions*.

The two controllers (or actions) are still lightweight. Each uses the
:doc:`Doctrine ORM library </book/doctrine>` to retrieve objects from the
database and the Templating component to render a template and return a
``Response`` object. The list template is now quite a bit simpler:
``Response`` object. The list ``list.php`` template is now quite a bit simpler:

.. code-block:: html+php

Expand All @@ -585,7 +607,7 @@ database and the Templating component to render a template and return a
<?php endforeach ?>
</ul>

The layout is nearly identical:
The ``layout.php`` file is nearly identical:

.. code-block:: html+php

Expand All @@ -605,12 +627,13 @@ The layout is nearly identical:

.. note::

The show template is left as an exercise, as it should be trivial to
create based on the list template.
The show ``show.php`` template is left as an exercise: updating it should be
really similar to updating the ``list.php`` template.

When Symfony's engine (called the ``Kernel``) boots up, it needs a map so
When Symfony's engine (called the Kernel) boots up, it needs a map so
that it knows which controllers to execute based on the request information.
A routing configuration map provides this information in a readable format:
A routing configuration map - ``app/config/routing.yml`` - provides this information
in a readable format:

.. code-block:: yaml

Expand All @@ -624,9 +647,8 @@ A routing configuration map provides this information in a readable format:
defaults: { _controller: AppBundle:Blog:show }

Now that Symfony is handling all the mundane tasks, the front controller
is dead simple. And since it does so little, you'll never have to touch
it once it's created (and if you use a `Symfony distribution`_, you won't
even need to create it!)::
``web/app.php`` is dead simple. And since it does so little, you'll never
have to touch it::

// web/app.php
require_once __DIR__.'/../app/bootstrap.php';
Expand All @@ -637,55 +659,29 @@ even need to create it!)::
$kernel = new AppKernel('prod', false);
$kernel->handle(Request::createFromGlobals())->send();

The front controller's only job is to initialize Symfony's engine (``Kernel``)
and pass it a ``Request`` object to handle. Symfony's core then uses the
routing map to determine which controller to call. Just like before, the
controller method is responsible for returning the final ``Response`` object.
There's really not much else to it.

For a visual representation of how Symfony handles each request, see the
:ref:`request flow diagram <request-flow-figure>`.

.. _where-symfony2-delivers:
The front controller's only job is to initialize Symfony's engine (called the
Kernel) and pass it a ``Request`` object to handle. The Symfony core
asks the router to inspect the request. The router matches the incoming URL
to a specific route and returns information about the route, including the
controller that should be executed. The correct controller from the matched
route is executed and your code inside the controller creates and returns the
appropriate ``Response`` object. The HTTP headers and content of the ``Response``
object are sent back to the client.

Where Symfony Delivers
~~~~~~~~~~~~~~~~~~~~~~

In the upcoming chapters, you'll learn more about how each piece of Symfony
works and the recommended organization of a project. For now, have a look
at how migrating the blog from flat PHP to Symfony has improved life:
It's a beautiful thing.

* Your application now has **clear and consistently organized code** (though
Symfony doesn't force you into this). This promotes **reusability** and
allows for new developers to be productive in your project more quickly;

* 100% of the code you write is for *your* application. You **don't need
to develop or maintain low-level utilities** such as autoloading,
:doc:`routing </book/routing>`, or rendering :doc:`controllers </book/controller>`;

* Symfony gives you **access to open source tools** such as Doctrine and the
Templating, Security, Form, Validation and Translation components (to name
a few);

* The application now enjoys **fully-flexible URLs** thanks to the Routing
component;

* Symfony's HTTP-centric architecture gives you access to powerful tools
such as **HTTP caching** powered by **Symfony's internal HTTP cache** or
more powerful tools such as `Varnish`_. This is covered in a later chapter
all about :doc:`caching </book/http_cache>`.

And perhaps best of all, by using Symfony, you now have access to a whole
set of **high-quality open source tools developed by the Symfony community**!
A good selection of Symfony community tools can be found on `KnpBundles.com`_.
.. figure:: /images/request-flow.png
:align: center
:alt: Symfony request flow

Better Templates
----------------
~~~~~~~~~~~~~~~~

If you choose to use it, Symfony comes standard with a templating engine
called `Twig`_ that makes templates faster to write and easier to read.
It means that the sample application could contain even less code! Take,
for example, the list template written in Twig:
for example, rewriting ``list.html.php`` template in Twig would look like
this:

.. code-block:: html+twig

Expand All @@ -707,7 +703,7 @@ for example, the list template written in Twig:
</ul>
{% endblock %}

The corresponding ``layout.html.twig`` template is also easier to write:
And rewriting ``layout.html.php`` template in Twig would look like this:

.. code-block:: html+twig

Expand All @@ -726,18 +722,52 @@ Twig is well-supported in Symfony. And while PHP templates will always
be supported in Symfony, the many advantages of Twig will continue to
be discussed. For more information, see the :doc:`templating chapter </book/templating>`.

Where Symfony Delivers
----------------------

In the upcoming chapters, you'll learn more about how each piece of Symfony
works and how you can organize your project. For now, celebrate at how migrating
the blog from flat PHP to Symfony has improved life:

* Your application now has **clear and consistently organized code** (though
Symfony doesn't force you into this). This promotes **reusability** and
allows for new developers to be productive in your project more quickly;

* 100% of the code you write is for *your* application. You **don't need
to develop or maintain low-level utilities** such as autoloading,
:doc:`routing </book/routing>`, or rendering :doc:`controllers </book/controller>`;

* Symfony gives you **access to open source tools** such as `Doctrine`_ and the
:doc:`Templating </components/templating/introduction>`,
:doc:`Security </components/security/introduction>`,
:doc:`Form </components/form/introduction>`, `Validator`_ and
:doc:`Translation </components/translation/introduction>` components (to name
a few);

* The application now enjoys **fully-flexible URLs** thanks to the Routing
component;

* Symfony's HTTP-centric architecture gives you access to powerful tools
such as **HTTP caching** powered by **Symfony's internal HTTP cache** or
more powerful tools such as `Varnish`_. This is covered in a later chapter
all about :doc:`caching </book/http_cache>`.

And perhaps best of all, by using Symfony, you now have access to a whole
set of **high-quality open source tools developed by the Symfony community**!
A good selection of Symfony community tools can be found on `KnpBundles.com`_.

Learn more from the Cookbook
----------------------------

* :doc:`/cookbook/templating/PHP`
* :doc:`/cookbook/controller/service`

.. _`Model-View-Controller`: https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller
.. _`Doctrine`: http://www.doctrine-project.org
.. _`SQL injection attack`: https://en.wikipedia.org/wiki/SQL_injection
.. _`Composer`: https://getcomposer.org
.. _`download Composer`: https://getcomposer.org/download/
.. _`Routing`: https://github.com/symfony/routing
.. _`Templating`: https://github.com/symfony/templating
.. _`KnpBundles.com`: http://knpbundles.com/
.. _`Twig`: http://twig.sensiolabs.org
.. _`Validator`: https://github.com/symfony/validator
.. _`Varnish`: https://www.varnish-cache.org/
.. _`PHPUnit`: http://www.phpunit.de
.. _`Symfony distribution`: https://github.com/symfony/symfony-standard
.. _`KnpBundles.com`: http://knpbundles.com/
.. _`Twig`: http://twig.sensiolabs.org
Loading