8000 Added annotations example to Linking to Pages examples by carlos-granados · Pull Request #5781 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

Added annotations example to Linking to Pages examples #5781

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

Merged
merged 4 commits into from
Nov 5, 2015
Merged
Changes from 1 commit
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
Next Next commit
Added annotations example to Linking to Pages examples
In the routing examples for the Linking to Pages section there were no annotations examples (which is what most people use). I have added these examples
  • Loading branch information
Carlos Granados committed Oct 12, 2015
commit 30e0dd4462b95808135d4fc34444dea299319058
28 changes: 28 additions & 0 deletions book/templating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,20 @@ configuration:

.. configuration-block::

.. code-block:: php-annotations

// src/AppBundle/Controller/WelcomeController.php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will also need the namespace declaration

class WelcomeController extends Controller
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the beginning of the annotations snippets we should put the use imports needed to make the code work:

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;

// ...

{
/**
* @Route("/", name="_welcome")
*/
public function indexAction()
{
// ...
}
}

.. code-block:: yaml

# app/config/routing.yml
Expand Down Expand Up @@ -918,6 +932,20 @@ route:

.. configuration-block::

.. code-block:: php-annotations

// src/AppBundle/Controller/ArticleController.php
class ArticleController extends Controller
{
/**
* @Route("/article/{slug}", name="article_show")
*/
public function showAction($slug)
{
// ...
}
}

.. code-block:: yaml

# app/config/routing.yml
Expand Down
0