Skip to content

Commit 4c61469

Browse files
committed
Fixed code examples in book/from_flat_to_symfony
1 parent e069e66 commit 4c61469

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

book/from_flat_php_to_symfony2.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ persisted to the database. Writing in flat PHP is quick and dirty:
2727

2828
<?php
2929
// index.php
30-
3130
$link = mysql_connect('localhost', 'myuser', 'mypassword');
3231
mysql_select_db('blog_db', $link);
3332

3433
$result = mysql_query('SELECT id, title FROM post', $link);
3534
?>
3635

36+
<!doctype html>
3737
<html>
3838
<head>
3939
<title>List of Posts</title>
@@ -54,6 +54,7 @@ persisted to the database. Writing in flat PHP is quick and dirty:
5454

5555
<?php
5656
mysql_close($link);
57+
?>
5758

5859
That's quick to write, fast to execute, and, as your app grows, impossible
5960
to maintain. There are several problems that need to be addressed:
@@ -85,7 +86,6 @@ the code that prepares the HTML "presentation":
8586

8687
<?php
8788
// index.php
88-
8989
$link = mysql_connect('localhost', 'myuser', 'mypassword');
9090
mysql_select_db('blog_db', $link);
9191

@@ -106,6 +106,7 @@ is primarily an HTML file that uses a template-like PHP syntax:
106106

107107
.. code-block:: html+php
108108

109+
<!doctype html>
109110
<html>
110111
<head>
111112
<title>List of Posts</title>
@@ -146,7 +147,6 @@ of the application are isolated in a new file called ``model.php``:
146147

147148
<?php
148149
// model.php
149-
150150
function open_database_connection()
151151
{
152152
$link = mysql_connect('localhost', 'myuser', 'mypassword');
@@ -543,8 +543,8 @@ them for you. Here's the same sample application, now built in Symfony2:
543543

544544
<?php
545545
// src/Acme/BlogBundle/Controller/BlogController.php
546-
547546
namespace Acme\BlogBundle\Controller;
547+
548548
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
549549

550550
class BlogController extends Controller
@@ -602,6 +602,7 @@ The layout is nearly identical:
602602
.. code-block:: html+php
603603

604604
<!-- app/Resources/views/layout.html.php -->
605+
<!doctype html>
605606
<html>
606607
<head>
607608
<title><?php echo $view['slots']->output('title', 'Default title') ?></title>
@@ -699,7 +700,6 @@ for example, the list template written in Twig:
699700
.. code-block:: html+jinja
700701

701702
{# src/Acme/BlogBundle/Resources/views/Blog/list.html.twig #}
702-
703703
{% extends "::layout.html.twig" %}
704704
{% block title %}List of Posts{% endblock %}
705705

@@ -708,7 +708,7 @@ for example, the list template written in Twig:
708708
<ul>
709709
{% for post in posts %}
710710
<li>
711-
<a href="{{ path('blog_show', { 'id': post.id }) }}">
711+
<a href="{{ path('blog_show', {'id': post.id}) }}">
712712
{{ post.title }}
713713
</a>
714714
</li>
@@ -721,7 +721,7 @@ The corresponding ``layout.html.twig`` template is also easier to write:
721721
.. code-block:: html+jinja
722722

723723
{# app/Resources/views/layout.html.twig #}
724-
724+
<!doctype html>
725725
<html>
726726
<head>
727727
<title>{% block title %}Default title{% endblock %}</title>

0 commit comments

Comments
 (0)