Skip to content

Commit

Permalink
[Routing] is usable without SensioFrameworkBundle since 3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
GuilhemN authored and xabbuh committed Jul 4, 2017
1 parent 9439177 commit c0e466a
Show file tree
Hide file tree
Showing 25 changed files with 60 additions and 60 deletions.
6 changes: 3 additions & 3 deletions best_practices/controllers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ for the homepage of our app:
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;
class DefaultController extends Controller
{
Expand Down Expand Up @@ -149,7 +149,7 @@ For example:
.. code-block:: php
use AppBundle\Entity\Post;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/{id}", name="admin_post_show")
Expand Down Expand Up @@ -202,9 +202,9 @@ flexible:
.. code-block:: php
use AppBundle\Entity\Post;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/comment/{postSlug}/new", name = "comment_new")
Expand Down
5 changes: 3 additions & 2 deletions best_practices/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ Using ``@Security``, this looks like:

.. code-block:: php
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\Routing\Annotation\Route;
// ...
/**
Expand All @@ -135,8 +135,8 @@ method on the ``Post`` object:
.. code-block:: php
use AppBundle\Entity\Post;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/{id}/edit", name="admin_post_edit")
Expand Down Expand Up @@ -191,6 +191,7 @@ Now you can reuse this method both in the template and in the security expressio
use AppBundle\Entity\Post;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route("/{id}/edit", name="admin_post_edit")
Expand Down
6 changes: 3 additions & 3 deletions components/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ routes with UTF-8 characters:
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;
class DefaultController extends Controller
{
Expand Down Expand Up @@ -442,7 +442,7 @@ You can also include UTF-8 strings as routing requirements:
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;
class DefaultController extends Controller
{
Expand Down Expand Up @@ -508,7 +508,7 @@ You can also include UTF-8 strings as routing requirements:
// ...
return $collection;
.. tip::

In addition to UTF-8 characters, the Routing component also supports all
Expand Down
22 changes: 10 additions & 12 deletions configuration/micro_kernel_trait.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,9 @@ your ``composer.json`` file to load from there:
}
}
Now, suppose you want to use Twig and load routes via annotations. For annotation
routing, you need SensioFrameworkExtraBundle. This comes with a normal Symfony project.
But in this case, you need to download it:

.. code-block:: bash
$ composer require sensio/framework-extra-bundle
Instead of putting *everything* in ``index.php``, create a new ``app/AppKernel.php``
to hold the kernel. Now it looks like this::
Now, suppose you want to use Twig and load routes via annotations. Instead of
putting *everything* in ``index.php``, create a new ``app/AppKernel.php`` to
hold the kernel. Now it looks like this::

// app/AppKernel.php

Expand All @@ -161,7 +154,6 @@ to hold the kernel. Now it looks like this::
$bundles = array(
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle()
);

if ($this->getEnvironment() == 'dev') {
Expand Down Expand Up @@ -209,6 +201,12 @@ to hold the kernel. Now it looks like this::
}
}


.. versionadded:: 3.4
Support for annotation routing without an external bundle was added in
Symfony 3.4. Prior to version 3.4, you needed to install the
SensioFrameworkExtraBundle.

Unlike the previous kernel, this loads an external ``app/config/config.yml`` file,
because the configuration started to get bigger:

Expand Down Expand Up @@ -261,7 +259,7 @@ has one file in it::
namespace App\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;

class MicroController extends Controller
{
Expand Down
6 changes: 3 additions & 3 deletions controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ This renders a page that prints a lucky (random) number::
// src/AppBundle/Controller/LuckyController.php
namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class LuckyController
{
Expand Down Expand Up @@ -59,7 +59,7 @@ class::
namespace AppBundle\Controller;

use Symfony\Component\HttpFoundation\Response;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;

class LuckyController
{
Expand Down Expand Up @@ -325,7 +325,7 @@ controller's service config:
// app/config/services.php
use AppBundle\Controller\LuckyController;
$container->register(LuckyController::class)
->setPublic(true)
->addTag('controller.service_arguments', [
Expand Down
3 changes: 3 additions & 0 deletions controller/service.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ syntax:
.. code-block:: php-annotations
# src/AppBundle/Controller/HelloController.php
// You need to use Sensio's annotation to specify a service id
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
// ...
/**
Expand Down
2 changes: 1 addition & 1 deletion controller/soap_web_service.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ can be retrieved via ``/soap?wsdl``::

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;
use AppBundle\Service\HelloService;

class HelloServiceController extends Controller
Expand Down
2 changes: 1 addition & 1 deletion controller/upload_file.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ Finally, you need to update the code of the controller that handles the form::
// src/AppBundle/Controller/ProductController.php
namespace AppBundle\ProductController;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use AppBundle\Entity\Product;
use AppBundle\Form\ProductType;

Expand Down
2 changes: 1 addition & 1 deletion doctrine/registration_form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,9 @@ into the database::

use AppBundle\Form\UserType;
use AppBundle\Entity\User;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;

class RegistrationController extends Controller
Expand Down
2 changes: 1 addition & 1 deletion page_creation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ random) number and prints it. To do that, create a "Controller class" and a
// src/AppBundle/Controller/LuckyController.php
namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class LuckyController
{
Expand Down
4 changes: 2 additions & 2 deletions quick_tour/the_big_picture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ because that will be explained in the next section)::

namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;

class DefaultController extends Controller
{
Expand Down Expand Up @@ -95,8 +95,8 @@ at the three lines of code above the ``indexAction()`` method::
// src/AppBundle/Controller/DefaultController.php
namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;

class DefaultController extends Controller
{
Expand Down
12 changes: 6 additions & 6 deletions quick_tour/the_controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ text content::
// src/AppBundle/Controller/DefaultController.php
namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

class DefaultController extends Controller
{
Expand Down Expand Up @@ -57,8 +57,8 @@ a new method called ``helloAction()`` with the following content::
// src/AppBundle/Controller/DefaultController.php
namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Routing\Annotation\Route;

class DefaultController extends Controller
{
Expand Down Expand Up @@ -114,7 +114,7 @@ Tweak the ``hello`` route by adding a new ``_format`` variable with ``html``
as its default value::

// src/AppBundle/Controller/DefaultController.php
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;

// ...

Expand Down Expand Up @@ -152,8 +152,8 @@ To restrict the formats supported by a given action, use the ``requirements``
option of the ``@Route()`` annotation::

// src/AppBundle/Controller/DefaultController.php
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Component\Routing\Annotation\Route;

// ...

Expand Down Expand Up @@ -253,9 +253,9 @@ forget to add the new ``use`` statement that imports this ``Request`` class)::
// src/AppBundle/Controller/DefaultController.php
namespace AppBundle\Controller;

use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;

class DefaultController extends Controller
{
Expand Down Expand Up @@ -335,7 +335,7 @@ And you can display the flash message in the template like this:
{% endfor %}

.. versionadded:: 3.3
The ``app.flashes()`` Twig function was introduced in Symfony 3.3. Prior,
The ``app.flashes()`` Twig function was introduced in Symfony 3.3. Prior,
you had to use ``app.session.flashBag()``.

Final Thoughts
Expand Down
6 changes: 3 additions & 3 deletions routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The route is simple:
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;
class BlogController extends Controller
{
Expand Down Expand Up @@ -174,7 +174,7 @@ To fix this, add a *requirement* that the ``{page}`` wildcard can *only* match n
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;
class BlogController extends Controller
{
Expand Down Expand Up @@ -272,7 +272,7 @@ So how can you make ``blog_list`` once again match when the user visits
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;
class BlogController extends Controller
{
Expand Down
4 changes: 2 additions & 2 deletions routing/custom_route_loader.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Loading Routes
The routes in a Symfony application are loaded by the
:class:`Symfony\\Bundle\\FrameworkBundle\\Routing\\DelegatingLoader`.
This loader uses several other loaders (delegates) to load resources of
different types, for instance YAML files or ``@Route`` and ``@Method`` annotations
in controller files. The specialized loaders implement
different types, for instance YAML files or ``@Route`` annotations in controller
files. The specialized loaders implement
:class:`Symfony\\Component\\Config\\Loader\\LoaderInterface`
and therefore have two important methods:
:method:`Symfony\\Component\\Config\\Loader\\LoaderInterface::supports`
Expand Down
10 changes: 5 additions & 5 deletions routing/hostname_pattern.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ You can also match on the HTTP *host* of the incoming request.
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;
class MainController extends Controller
{
Expand Down Expand Up @@ -96,7 +96,7 @@ you can use placeholders in your hostname:
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;
class MainController extends Controller
{
Expand Down Expand Up @@ -173,7 +173,7 @@ instance, if you want to match both ``m.example.com`` and
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;
class MainController extends Controller
{
Expand Down Expand Up @@ -266,7 +266,7 @@ instance, if you want to match both ``m.example.com`` and
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;
class MainController extends Controller
{
Expand Down Expand Up @@ -367,7 +367,7 @@ You can also set the host option on imported routes:
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\Routing\Annotation\Route;
/**
* @Route(host="hello.example.com")
Expand Down
2 changes: 1 addition & 1 deletion routing/redirect_trailing_slash.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ system, as explained below:
// src/AppBundle/Controller/RedirectingController.php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
class RedirectingController extends Controller
{
Expand Down

0 comments on commit c0e466a

Please sign in to comment.