Skip to content

Update the_big_picture.rst #19820

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 41 additions & 3 deletions quick_tour/the_big_picture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ safe & easy!) and offers long-term support.
Downloading Symfony
-------------------

First, make sure you've installed `Composer`_ and have PHP 8.1 or higher.
First, make sure you've installed `Composer`_ and have PHP 8.2 or higher.

Ready? In a terminal, run:

Expand Down Expand Up @@ -135,8 +135,46 @@ Try the page out by going to ``http://localhost:8000/hello/Symfony``. You should
see: Hello Symfony! The value of the ``{name}`` in the URL is available as a ``$name``
argument in your controller.

But by using attributes, the route and controller live right next to each
other. Need another page? Add another route and method in ``DefaultController``::
But this can be even simpler! Comment-out the YAML route by adding the
``#`` character. Uncomment previous code to avoid a notfound error.

.. code-block:: diff

// Uncomment the template code to avoid an error
controllers:
resource:
path: ../src/Controller/
namespace: App\Controller

type: attribute
# config/routes.yaml
# index:
# path: /hello/{name}
# controller: 'App\Controller\DefaultController::index'

Instead, add the route *right above* the controller method:

.. code-block:: diff

<?php
// src/Controller/DefaultController.php
namespace App\Controller;

use Symfony\Component\HttpFoundation\Response;
+ use Symfony\Component\Routing\Attribute\Route;

class DefaultController
{
+ #[Route('/hello/{name}', methods: ['GET'])]
public function index(string $name): Response
{
// ...
}
}

This works just like before! But by using attributes, the route and controller
live right next to each other. Need another page? Add another route and method
in ``DefaultController``::

// src/Controller/DefaultController.php
namespace App\Controller;
Expand Down
Loading