Skip to content

Commit 6ae19f0

Browse files
committed
[WIP] Removing multiple formats - it makes no sense here
1 parent 1297c75 commit 6ae19f0

File tree

1 file changed

+16
-54
lines changed

1 file changed

+16
-54
lines changed

book/page_creation.rst

Lines changed: 16 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -35,69 +35,31 @@ Creating a Page: Route and Controller
3535
Before continuing, make sure you've read the :doc:`Installation </book/installation>`
3636
chapter and can access your new Symfony app in the browser.
3737

38-
Suppose you want to create a page ``/lucky/number`` that generates a lucky (well,
38+
Suppose you want to create a page - ``/lucky/number`` - that generates a lucky (well,
3939
random) number and prints it. To do that, create a "Controller class" and a
4040
"controller" method inside of it that will be executed when someone goes to
4141
``/lucky/number``::
4242

43-
.. configuration-block::
44-
45-
.. code-block:: php-annotations
46-
47-
// src/AppBundle/Controller/LuckyController.php
48-
namespace AppBundle\Controller;
43+
// src/AppBundle/Controller/LuckyController.php
44+
namespace AppBundle\Controller;
4945

50-
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
51-
use Symfony\Component\HttpFoundation\Response;
46+
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
47+
use Symfony\Component\HttpFoundation\Response;
5248

53-
class LuckyController
49+
class LuckyController
50+
{
51+
/**
52+
* @Route("/lucky/number")
53+
*/
54+
public function numberAction()
5455
{
55-
/**
56-
* @Route("/lucky/number")
57-
*/
58-
public function numberAction()
59-
{
60-
$number = rand(0, 100);
56+
$number = rand(0, 100);
6157

62-
return new Response(
63-
'<html><body>Lucky number: '.$number.'</body></html>'
64-
);
65-
}
58+
return new Response(
59+
'<html><body>Lucky number: '.$number.'</body></html>'
60+
);
6661
}
67-
68-
.. code-block:: yaml
69-
70-
# app/config/routing.yml
71-
lucky_number:
72-
path: /lucky/number
73-
defaults: { _controller: AppBundle:Lucky:number }
74-
75-
.. code-block:: xml
76-
77-
<!-- app/config/routing.xml -->
78-
<?xml version="1.0" encoding="UTF-8" ?>
79-
<routes xmlns="http://symfony.com/schema/routing"
80-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
81-
xsi:schemaLocation="http://symfony.com/schema/routing
82-
http://symfony.com/schema/routing/routing-1.0.xsd">
83-
84-
<route id="lucky_number" path="/lucky/number">
85-
<default key="_controller">AppBundle:Lucky:number</default>
86-
</route>
87-
</routes>
88-
89-
.. code-block:: php
90-
91-
// app/config/routing.php
92-
use Symfony\Component\Routing\RouteCollection;
93-
use Symfony\Component\Routing\Route;
94-
95-
$collection = new RouteCollection();
96-
$collection->add('lucky_number', new Route('/lucky/number', array(
97-
'_controller' => 'AppBundle:Lucky:number',
98-
)));
99-
100-
return $collection;
62+
}
10163

10264
"Controller class" is a convenient way to group several "controllers" together.
10365

0 commit comments

Comments
 (0)