Skip to content

Commit 513f481

Browse files
committed
updating most of the quick tour
1 parent 26fcadc commit 513f481

File tree

3 files changed

+41
-39
lines changed

3 files changed

+41
-39
lines changed

quick_tour/the_big_picture.rst

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ because that will be explained in the next section)::
5959
/**
6060
* @Route("/", name="homepage")
6161
*/
62-
public function indexAction()
62+
public function index()
6363
{
6464
return $this->render('default/index.html.twig', [
6565
// ...
@@ -69,12 +69,12 @@ because that will be explained in the next section)::
6969

7070
In Symfony applications, **controllers** are usually PHP classes whose names
7171
are suffixed with the ``Controller`` word. In this example, the controller
72-
is called ``Default`` and the PHP class is called ``DefaultController``.
72+
is called ``DefaultController``.
7373

7474
The methods defined in a controller are called **actions**, they are usually
7575
associated with one URL of the application and their names are suffixed
76-
with ``Action``. In this example, the ``Default`` controller has only one
77-
action called ``index`` and defined in the ``indexAction()`` method.
76+
with ``Action``. In this example, the ``DefaultController`` has only one
77+
action called ``index()``.
7878

7979
Actions are usually very short - around 10-15 lines of code - because they
8080
just call other parts of the application to get or generate the needed
@@ -90,7 +90,7 @@ Routing
9090
Symfony routes each request to the action that handles it by matching the
9191
requested URL against the paths configured by the application. Open again
9292
the ``src/Controller/DefaultController.php`` file and take a look
93-
at the three lines of code above the ``indexAction()`` method::
93+
at the three lines of code above the ``index()`` method::
9494

9595
// src/Controller/DefaultController.php
9696
namespace App\Controller;
@@ -103,7 +103,7 @@ at the three lines of code above the ``indexAction()`` method::
103103
/**
104104
* @Route("/", name="homepage")
105105
*/
106-
public function indexAction()
106+
public function index()
107107
{
108108
return $this->render('default/index.html.twig', [
109109
// ...
@@ -126,7 +126,7 @@ but later it'll be useful for linking pages.
126126

127127
Considering all this, the ``@Route("/", name="homepage")`` annotation creates a
128128
new route called ``homepage`` which makes Symfony execute the ``index`` action
129-
of the ``Default`` controller when the user browses the ``/`` path of the application.
129+
of the ``DefaultController`` when the user browses the ``/`` path of the application.
130130

131131
.. tip::
132132

@@ -175,9 +175,9 @@ Working with Environments
175175
-------------------------
176176

177177
Now that you have a better understanding of how Symfony works, take a closer
178-
look at the bottom of any Symfony rendered page. You should notice a small
179-
bar with the Symfony logo. This is the "web debug toolbar" and it is a Symfony
180-
developer's best friend!
178+
look at the bottom of any Symfony rendered page. If you've installed the profiler
179+
with ``composer require profiler``, you should notice a small bar with the Symfony
180+
logo. This is the "web debug toolbar" and it is a Symfony developer's best friend!
181181

182182
.. image:: /_images/quick_tour/web_debug_toolbar.png
183183
:align: center
@@ -210,11 +210,12 @@ application. Symfony defines two environments by default: ``dev`` (suited for
210210
when developing the application locally) and ``prod`` (optimized for when
211211
executing the application on production).
212212

213-
When you visit the ``http://localhost:8000`` URL in your browser, you're
214-
executing your Symfony application in the ``dev`` environment. To visit
215-
your application in the ``prod`` environment, visit the ``http://localhost:8000/index.php``
216-
URL instead. If you prefer to always show the ``dev`` environment in the
217-
URL, you can visit ``http://localhost:8000/index.php`` URL.
213+
The environment is determined by the ``APP_ENV`` environment variable, which is
214+
set in the ``.env`` file while developing. By default, this value is set to ``dev``.
215+
This means that, right now, hen you visit the ``http://localhost:8000`` URL in your
216+
browser, you're executing your Symfony application in the ``dev`` environment. To
217+
visit your application in the ``prod`` environment, open your ``.env`` file and
218+
set ``APP_ENV`` to ``prod`` and ``APP_DEBUG`` to ``0``.
218219

219220
The main difference between environments is that ``dev`` is optimized to
220221
provide lots of information to the developer, which means worse application
@@ -224,26 +225,30 @@ toolbar.
224225

225226
The other difference between environments is the configuration options used
226227
to execute the application. When you access the ``dev`` environment, Symfony
227-
loads the ``app/config/config_dev.yml`` configuration file. When you access
228-
the ``prod`` environment, Symfony loads ``app/config/config_prod.yml`` file.
228+
loads any configuration files from the ``config/packages/dev`` directory. When you
229+
access the ``prod`` environment, Symfony loads files from the ``config/packages/prod``
230+
directory.
229231

230232
Typically, the environments share a large amount of configuration options.
231-
For that reason, you put your common configuration in ``config.yml`` and
232-
override the specific configuration file for each environment where necessary:
233+
For that reason, any configuration files stored directly in ``config/packages``
234+
are loaded in *all* environments. Then, configuration files in the ``dev/`` sub-directory
235+
can *override* that config.
233236

234237
.. code-block:: yaml
235238
236-
# app/config/config_dev.yml
237-
imports:
238-
- { resource: config.yml }
239+
# config/packages/routing.yaml
240+
framework:
241+
router:
242+
strict_requirements: ~
239243
240-
web_profiler:
241-
toolbar: true
242-
intercept_redirects: false
244+
.. code-block:: yaml
245+
# config/packages/dev/routing.yaml
246+
framework:
247+
router:
248+
strict_requirements: true
243249
244-
In this example, the ``config_dev.yml`` configuration file imports the common
245-
``config.yml`` file and then overrides any existing web debug toolbar configuration
246-
with its own options.
250+
In this example, the ``strict_requirements`` is overridden and set to ``true``
251+
*only* in the ``dev`` environment.
247252

248253
For more details on environments, see
249254
:ref:`the "Environments" section <page-creation-environments>` of the

quick_tour/the_controller.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ text content::
3131
/**
3232
* @Route("/", name="homepage")
3333
*/
34-
public function indexAction()
34+
public function index()
3535
{
3636
return new Response('Welcome to Symfony!');
3737
}
@@ -338,7 +338,5 @@ Final Thoughts
338338
--------------
339339

340340
That's all there is to it and I'm not even sure you have spent the full
341-
10 minutes. You were briefly introduced to bundles in the first part and
342-
all the features you've learned about so far are part of the core FrameworkBundle.
343-
But thanks to bundles, everything in Symfony can be extended or replaced.
344-
That's the topic of the :doc:`next part of this tutorial <the_architecture>`.
341+
10 minutes. Let's move onto something *very* interesting: the fact that everything
342+
in Symfony can be extended or replaced. That's the topic of the :doc:`next part of this tutorial <the_architecture>`.

quick_tour/the_view.rst

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,25 +196,24 @@ And what if you want to embed the result of another controller in a template?
196196
That's very useful when working with Ajax, or when the embedded template
197197
needs some variable not available in the main template.
198198

199-
Suppose you've created a ``topArticlesAction()`` controller method to display
199+
Suppose you've created a ``topArticles()`` controller method to display
200200
the most popular articles of your website. If you want to "render" the result
201201
of that method (usually some HTML content) inside the ``index`` template,
202202
use the ``render()`` function:
203203

204204
.. code-block:: twig
205205
206206
{# templates/index.html.twig #}
207-
{{ render(controller('AppBundle:Default:topArticles')) }}
207+
{{ render(controller('App\\DefaultController::topArticles')) }}
208208
209209
Here, the ``render()`` and ``controller()`` functions use the special
210-
``AppBundle:Default:topArticles`` syntax to refer to the ``topArticlesAction()``
211-
action of the ``Default`` controller (the ``AppBundle`` part will be explained
212-
later)::
210+
``App\\DefaultController::topArticles`` syntax to refer to the ``topArticles()``
211+
action of the ``Defaultcontroller``::
213212

214213
// src/Controller/DefaultController.php
215214
class DefaultController extends Controller
216215
{
217-
public function topArticlesAction()
216+
public function topArticles()
218217
{
219218
// look for the most popular articles in the database
220219
$articles = ...;

0 commit comments

Comments
 (0)