diff --git a/routing/conditions.rst b/routing/conditions.rst
index 6358ff608f4..735effa4459 100644
--- a/routing/conditions.rst
+++ b/routing/conditions.rst
@@ -12,13 +12,15 @@ define arbitrary matching logic, use the ``conditions`` routing option:
.. code-block:: yaml
+ # config/routes.yaml
contact:
- path: /contact
- defaults: { _controller: AcmeDemoBundle:Main:contact }
- condition: "context.getMethod() in ['GET', 'HEAD'] and request.headers.get('User-Agent') matches '/firefox/i'"
+ path: /contact
+ controller: 'App\Controller\DefaultController::contact'
+ condition: "context.getMethod() in ['GET', 'HEAD'] and request.headers.get('User-Agent') matches '/firefox/i'"
.. code-block:: xml
+
- AcmeDemoBundle:Main:contact
+ App\Controller\DefaultController::contact
context.getMethod() in ['GET', 'HEAD'] and request.headers.get('User-Agent') matches '/firefox/i'
.. code-block:: php
+ // config/routes.php
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;
$collection = new RouteCollection();
$collection->add('contact', new Route(
'/contact', array(
- '_controller' => 'AcmeDemoBundle:Main:contact',
+ '_controller' => 'App\Controller\DefaultController::contact',
),
array(),
array(),
diff --git a/routing/custom_route_loader.rst b/routing/custom_route_loader.rst
index ac32a9d9c44..4ccddcaacb0 100644
--- a/routing/custom_route_loader.rst
+++ b/routing/custom_route_loader.rst
@@ -36,18 +36,18 @@ and therefore have two important methods:
:method:`Symfony\\Component\\Config\\Loader\\LoaderInterface::supports`
and :method:`Symfony\\Component\\Config\\Loader\\LoaderInterface::load`.
-Take these lines from the ``routing.yml`` in the Symfony Standard Edition:
+Take these lines from the ``routes.yaml`` in the Symfony Standard Edition:
.. code-block:: yaml
# config/routes.yaml
- app:
- resource: '@AppBundle/Controller/'
- type: annotation
+ controllers:
+ resource: ../src/Controller/
+ type: annotation
When the main loader parses this, it tries all registered delegate loaders and calls
their :method:`Symfony\\Component\\Config\\Loader\\LoaderInterface::supports`
-method with the given resource (``@AppBundle/Controller/``)
+method with the given resource (``../src/Controller/``)
and type (``annotation``) as arguments. When one of the loader returns ``true``,
its :method:`Symfony\\Component\\Config\\Loader\\LoaderInterface::load` method
will be called, which should return a :class:`Symfony\\Component\\Routing\\RouteCollection`
@@ -56,7 +56,7 @@ containing :class:`Symfony\\Component\\Routing\\Route` objects.
.. note::
Routes loaded this way will be cached by the Router the same way as
- when they are defined in one of the default formats (e.g. XML, YML,
+ when they are defined in one of the default formats (e.g. XML, YAML,
PHP file).
Creating a custom Loader
@@ -97,7 +97,7 @@ you do. The resource name itself is not actually used in the example::
// prepare a new route
$path = '/extra/{parameter}';
$defaults = array(
- '_controller' => 'AppBundle:Extra:extra',
+ '_controller' => 'App\Controller\ExtraController::extra',
);
$requirements = array(
'parameter' => '\d+',
@@ -120,8 +120,7 @@ you do. The resource name itself is not actually used in the example::
}
Make sure the controller you specify really exists. In this case you
-have to create an ``extraAction()`` method in the ``ExtraController``
-of the ``AppBundle``::
+have to create an ``extra()`` method in the ``ExtraController``::
// src/Controller/ExtraController.php
namespace App\Controller;
@@ -131,7 +130,7 @@ of the ``AppBundle``::
class ExtraController extends Controller
{
- public function extraAction($parameter)
+ public function extra($parameter)
{
return new Response($parameter);
}
@@ -152,6 +151,7 @@ Now define a service for the ``ExtraLoader``:
.. code-block:: xml
+
import($resource, $type);
diff --git a/routing/external_resources.rst b/routing/external_resources.rst
index cb4600529c6..1493d2f3ce9 100644
--- a/routing/external_resources.rst
+++ b/routing/external_resources.rst
@@ -14,9 +14,9 @@ This can be done by "importing" directories into the routing configuration:
.. code-block:: yaml
# config/routes.yaml
- app:
- resource: '@AppBundle/Controller/'
- type: annotation # required to enable the Annotation reader for this resource
+ controllers:
+ resource: ../src/Controller/
+ type: annotation
.. code-block:: xml
@@ -27,8 +27,7 @@ This can be done by "importing" directories into the routing configuration:
xsi:schemaLocation="http://symfony.com/schema/routing
http://symfony.com/schema/routing/routing-1.0.xsd">
-
-
+
.. code-block:: php
@@ -38,27 +37,23 @@ This can be done by "importing" directories into the routing configuration:
$collection = new RouteCollection();
$collection->addCollection(
- // second argument is the type, which is required to enable
- // the annotation reader for this resource
- $loader->import("@AppBundle/Controller/", "annotation")
+ $loader->import("../src/Controller/", "annotation")
);
return $collection;
.. note::
- When importing resources from YAML, the key (e.g. ``app``) is meaningless.
+ When importing resources from YAML, the key (e.g. ``controllers``) is meaningless.
Just be sure that it's unique so no other lines override it.
The ``resource`` key loads the given routing resource. In this example the
-resource is a directory, where the ``@AppBundle`` shortcut syntax resolves
-to the full path of the AppBundle. When pointing to a directory, all files
-in that directory are parsed and put into the routing.
+resource is a directory and all files in that directory are parsed and put into
+the routing.
.. note::
- You can also include other routing configuration files, this is often
- used to import the routing of third party bundles:
+ You can also include other routing configuration files:
.. configuration-block::
@@ -66,7 +61,7 @@ in that directory are parsed and put into the routing.
# config/routes.yaml
app:
- resource: '@AcmeOtherBundle/Resources/config/routing.yml'
+ resource: '@ThirdPartyBundle/Resources/config/routing.yaml'
.. code-block:: xml
@@ -77,7 +72,7 @@ in that directory are parsed and put into the routing.
xsi:schemaLocation="http://symfony.com/schema/routing
http://symfony.com/schema/routing/routing-1.0.xsd">
-
+
.. code-block:: php
@@ -87,7 +82,7 @@ in that directory are parsed and put into the routing.
$collection = new RouteCollection();
$collection->addCollection(
- $loader->import("@AcmeOtherBundle/Resources/config/routing.php")
+ $loader->import("@ThirdPartyBundle/Resources/config/routing.php")
);
return $collection;
@@ -96,7 +91,7 @@ Prefixing Imported Routes
~~~~~~~~~~~~~~~~~~~~~~~~~
You can also choose to provide a "prefix" for the imported routes. For example,
-suppose you want to prefix all routes in the AppBundle with ``/site`` (e.g.
+suppose you want to prefix all application routes with ``/site`` (e.g.
``/site/blog/{slug}`` instead of ``/blog/{slug}``):
.. configuration-block::
@@ -104,8 +99,8 @@ suppose you want to prefix all routes in the AppBundle with ``/site`` (e.g.
.. code-block:: yaml
# config/routes.yaml
- app:
- resource: '@AppBundle/Controller/'
+ controllers:
+ resource: '../src/Controller/'
type: annotation
prefix: /site
@@ -119,7 +114,7 @@ suppose you want to prefix all routes in the AppBundle with ``/site`` (e.g.
http://symfony.com/schema/routing/routing-1.0.xsd">
@@ -129,7 +124,7 @@ suppose you want to prefix all routes in the AppBundle with ``/site`` (e.g.
// config/routes.php
use Symfony\Component\Routing\RouteCollection;
- $app = $loader->import('@AppBundle/Controller/', 'annotation');
+ $app = $loader->import('../src/Controller/', 'annotation');
$app->addPrefix('/site');
$collection = new RouteCollection();
diff --git a/routing/extra_information.rst b/routing/extra_information.rst
index cdf35bad73b..85d09f22777 100644
--- a/routing/extra_information.rst
+++ b/routing/extra_information.rst
@@ -15,11 +15,11 @@ to your controller, and as attributes of the ``Request`` object:
# config/routes.yaml
blog:
- path: /blog/{page}
+ path: /blog/{page}
+ controller: App\Controller\BlogController::index
defaults:
- _controller: AppBundle:Blog:index
- page: 1
- title: "Hello world!"
+ page: 1
+ title: "Hello world!"
.. code-block:: xml
@@ -31,7 +31,7 @@ to your controller, and as attributes of the ``Request`` object:
http://symfony.com/schema/routing/routing-1.0.xsd">
- AppBundle:Blog:index
+ App\Controller\BlogController::index
1
Hello world!
@@ -45,7 +45,7 @@ to your controller, and as attributes of the ``Request`` object:
$collection = new RouteCollection();
$collection->add('blog', new Route('/blog/{page}', array(
- '_controller' => 'AppBundle:Blog:index',
+ '_controller' => 'App\Controller\BlogController::index',
'page' => 1,
'title' => 'Hello world!',
)));
@@ -55,7 +55,7 @@ to your controller, and as attributes of the ``Request`` object:
Now, you can access this extra parameter in your controller, as an argument
to the controller method::
- public function indexAction($page, $title)
+ public function index($page, $title)
{
// ...
}
@@ -63,8 +63,8 @@ to the controller method::
Alternatively, the title could be accessed through the ``Request`` object::
use Symfony\Component\HttpFoundation\Request;
-
- public function indexAction(Request $request, $page)
+
+ public function index(Request $request, $page)
{
$title = $request->attributes->get('title');
diff --git a/routing/hostname_pattern.rst b/routing/hostname_pattern.rst
index 93bc5e00d93..a1086c1a3b6 100644
--- a/routing/hostname_pattern.rst
+++ b/routing/hostname_pattern.rst
@@ -21,7 +21,7 @@ You can also match on the HTTP *host* of the incoming request.
/**
* @Route("/", name="mobile_homepage", host="m.example.com")
*/
- public function mobileHomepageAction()
+ public function mobileHomepage()
{
// ...
}
@@ -29,7 +29,7 @@ You can also match on the HTTP *host* of the incoming request.
/**
* @Route("/", name="homepage")
*/
- public function homepageAction()
+ public function homepage()
{
// ...
}
@@ -37,17 +37,19 @@ You can also match on the HTTP *host* of the incoming request.
.. code-block:: yaml
+ # config/routes.yaml
mobile_homepage:
- path: /
- host: m.example.com
- defaults: { _controller: AppBundle:Main:mobileHomepage }
+ path: /
+ host: m.example.com
+ controller: App\Controller\MainController::mobileHomepage
homepage:
- path: /
- defaults: { _controller: AppBundle:Main:homepage }
+ path: /
+ controller: App\Controller\MainController::homepage
.. code-block:: xml
+
- AppBundle:Main:mobileHomepage
+ App\Controller\MainController::mobileHomepage
- AppBundle:Main:homepage
+ App\Controller\MainController::homepage
.. code-block:: php
+ // config/routes.php
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;
$collection = new RouteCollection();
$collection->add('mobile_homepage', new Route('/', array(
- '_controller' => 'AppBundle:Main:mobileHomepage',
+ '_controller' => 'App\Controller\MainController::mobileHomepage',
), array(), array(), 'm.example.com'));
$collection->add('homepage', new Route('/', array(
- '_controller' => 'AppBundle:Main:homepage',
+ '_controller' => 'App\Controller\MainController::homepage',
)));
return $collection;
@@ -103,7 +106,7 @@ you can use placeholders in your hostname:
/**
* @Route("/", name="projects_homepage", host="{project_name}.example.com")
*/
- public function projectsHomepageAction()
+ public function projectsHomepage()
{
// ...
}
@@ -111,7 +114,7 @@ you can use placeholders in your hostname:
/**
* @Route("/", name="homepage")
*/
- public function homepageAction()
+ public function homepage()
{
// ...
}
@@ -119,17 +122,19 @@ you can use placeholders in your hostname:
.. code-block:: yaml
+ # config/routes.yaml
projects_homepage:
- path: /
- host: "{project_name}.example.com"
- defaults: { _controller: AppBundle:Main:projectsHomepage }
+ path: /
+ host: "{project_name}.example.com"
+ controller: App\Controller\MainController::projectsHomepage
homepage:
- path: /
- defaults: { _controller: AppBundle:Main:homepage }
+ path: /
+ controller: App\Controller\MainController::homepage
.. code-block:: xml
+
- AppBundle:Main:projectsHomepage
+ App\Controller\MainController::projectsHomepage
- AppBundle:Main:homepage
+ App\Controller\MainController::homepage
.. code-block:: php
+ // config/routes.php
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;
$collection = new RouteCollection();
$collection->add('project_homepage', new Route('/', array(
- '_controller' => 'AppBundle:Main:projectsHomepage',
+ '_controller' => 'App\Controller\MainController::projectsHomepage',
), array(), array(), '{project_name}.example.com'));
$collection->add('homepage', new Route('/', array(
- '_controller' => 'AppBundle:Main:homepage',
+ '_controller' => 'App\Controller\MainController::homepage',
)));
return $collection;
@@ -186,7 +192,7 @@ instance, if you want to match both ``m.example.com`` and
* requirements={"subdomain"="m|mobile"}
* )
*/
- public function mobileHomepageAction()
+ public function mobileHomepage()
{
// ...
}
@@ -194,7 +200,7 @@ instance, if you want to match both ``m.example.com`` and
/**
* @Route("/", name="homepage")
*/
- public function homepageAction()
+ public function homepage()
{
// ...
}
@@ -202,21 +208,23 @@ instance, if you want to match both ``m.example.com`` and
.. code-block:: yaml
+ # config/routes.yaml
mobile_homepage:
- path: /
- host: "{subdomain}.example.com"
+ path: /
+ host: "{subdomain}.example.com"
+ controller: App\Controller\MainController::mobileHomepage
defaults:
- _controller: AppBundle:Main:mobileHomepage
subdomain: m
requirements:
subdomain: m|mobile
homepage:
- path: /
- defaults: { _controller: AppBundle:Main:homepage }
+ path: /
+ controller: App\Controller\MainController::homepage
.. code-block:: xml
+
- AppBundle:Main:mobileHomepage
+ App\Controller\MainController::mobileHomepage
m
m|mobile
- AppBundle:Main:homepage
+ App\Controller\MainController::homepage
.. code-block:: php
+ // config/routes.php
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;
$collection = new RouteCollection();
$collection->add('mobile_homepage', new Route('/', array(
- '_controller' => 'AppBundle:Main:mobileHomepage',
+ '_controller' => 'App\Controller\MainController::mobileHomepage',
'subdomain' => 'm',
), array(
'subdomain' => 'm|mobile',
), array(), '{subdomain}.example.com'));
$collection->add('homepage', new Route('/', array(
- '_controller' => 'AppBundle:Main:homepage',
+ '_controller' => 'App\Controller\MainController::homepage',
)));
return $collection;
@@ -279,7 +288,7 @@ instance, if you want to match both ``m.example.com`` and
* requirements={"domain"="%domain%"}
* )
*/
- public function mobileHomepageAction()
+ public function mobileHomepage()
{
// ...
}
@@ -287,7 +296,7 @@ instance, if you want to match both ``m.example.com`` and
/**
* @Route("/", name="homepage")
*/
- public function homepageAction()
+ public function homepage()
{
// ...
}
@@ -295,21 +304,23 @@ instance, if you want to match both ``m.example.com`` and
.. code-block:: yaml
+ # config/routes.yaml
mobile_homepage:
- path: /
- host: "m.{domain}"
+ path: /
+ host: "m.{domain}"
+ controller: App\Controller\MainController::mobileHomepage
defaults:
- _controller: AppBundle:Main:mobileHomepage
domain: '%domain%'
requirements:
domain: '%domain%'
homepage:
- path: /
- defaults: { _controller: AppBundle:Main:homepage }
+ path: /
+ controller: App\Controller\MainController::homepage
.. code-block:: xml
+
- AppBundle:Main:mobileHomepage
+ App\Controller\MainController::mobileHomepage
%domain%
%domain%
- AppBundle:Main:homepage
+ App\Controller\MainController::homepage
.. code-block:: php
+ // config/routes.php
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;
$collection = new RouteCollection();
$collection->add('mobile_homepage', new Route('/', array(
- '_controller' => 'AppBundle:Main:mobileHomepage',
+ '_controller' => 'App\Controller\MainController::mobileHomepage',
'domain' => '%domain%',
), array(
'domain' => '%domain%',
), array(), 'm.{domain}'));
$collection->add('homepage', new Route('/', array(
- '_controller' => 'AppBundle:Main:homepage',
+ '_controller' => 'App\Controller\MainController::homepage',
)));
return $collection;
@@ -379,24 +391,27 @@ You can also set the host option on imported routes:
.. code-block:: yaml
+ # config/routes.yaml
app_hello:
- resource: '@AppBundle/Resources/config/routing.yml'
+ resource: '@ThirdPartyBundle/Resources/config/routing.yml'
host: "hello.example.com"
.. code-block:: xml
+
-
+
.. code-block:: php
- $collection = $loader->import("@AppBundle/Resources/config/routing.php");
+ // config/routes.php
+ $collection = $loader->import("@ThirdPartyBundle/Resources/config/routing.php");
$collection->setHost('hello.example.com');
return $collection;
diff --git a/routing/optional_placeholders.rst b/routing/optional_placeholders.rst
index 462bd71e8f5..e34bad57989 100644
--- a/routing/optional_placeholders.rst
+++ b/routing/optional_placeholders.rst
@@ -21,7 +21,7 @@ the available blog posts for this imaginary blog application:
/**
* @Route("/blog")
*/
- public function indexAction()
+ public function index()
{
// ...
}
@@ -31,8 +31,8 @@ the available blog posts for this imaginary blog application:
# config/routes.yaml
blog:
- path: /blog
- defaults: { _controller: AppBundle:Blog:index }
+ path: /blog
+ controller: App\Controller\BlogController::index
.. code-block:: xml
@@ -44,7 +44,7 @@ the available blog posts for this imaginary blog application:
http://symfony.com/schema/routing/routing-1.0.xsd">
- AppBundle:Blog:index
+ App\Controller\BlogController::index
@@ -56,7 +56,7 @@ the available blog posts for this imaginary blog application:
$collection = new RouteCollection();
$collection->add('blog', new Route('/blog', array(
- '_controller' => 'AppBundle:Blog:index',
+ '_controller' => 'App\Controller\BlogController::index',
)));
return $collection;
@@ -77,7 +77,7 @@ entries? Update the route to have a new ``{page}`` placeholder:
/**
* @Route("/blog/{page}")
*/
- public function indexAction($page)
+ public function index($page)
{
// ...
}
@@ -86,8 +86,8 @@ entries? Update the route to have a new ``{page}`` placeholder:
# config/routes.yaml
blog:
- path: /blog/{page}
- defaults: { _controller: AppBundle:Blog:index }
+ path: /blog/{page}
+ controller: App\Controller\BlogController::index
.. code-block:: xml
@@ -99,7 +99,7 @@ entries? Update the route to have a new ``{page}`` placeholder:
http://symfony.com/schema/routing/routing-1.0.xsd">
- AppBundle:Blog:index
+ App\Controller\BlogController::index
@@ -111,7 +111,7 @@ entries? Update the route to have a new ``{page}`` placeholder:
$collection = new RouteCollection();
$collection->add('blog', new Route('/blog/{page}', array(
- '_controller' => 'AppBundle:Blog:index',
+ '_controller' => 'App\Controller\BlogController::index',
)));
return $collection;
@@ -137,7 +137,7 @@ This is done by including it in the ``defaults`` collection:
/**
* @Route("/blog/{page}", defaults={"page" = 1})
*/
- public function indexAction($page)
+ public function index($page)
{
// ...
}
@@ -146,8 +146,9 @@ This is done by including it in the ``defaults`` collection:
# config/routes.yaml
blog:
- path: /blog/{page}
- defaults: { _controller: AppBundle:Blog:index, page: 1 }
+ path: /blog/{page}
+ controller: App\Controller\BlogController::index
+ defaults: { page: 1 }
.. code-block:: xml
@@ -159,7 +160,7 @@ This is done by including it in the ``defaults`` collection:
http://symfony.com/schema/routing/routing-1.0.xsd">
- AppBundle:Blog:index
+ App\Controller\BlogController::index
1
@@ -172,7 +173,7 @@ This is done by including it in the ``defaults`` collection:
$collection = new RouteCollection();
$collection->add('blog', new Route('/blog/{page}', array(
- '_controller' => 'AppBundle:Blog:index',
+ '_controller' => 'App\Controller\BlogController::index',
'page' => 1,
)));
diff --git a/routing/redirect_in_config.rst b/routing/redirect_in_config.rst
index b1b8be131e6..89864c4c06c 100644
--- a/routing/redirect_in_config.rst
+++ b/routing/redirect_in_config.rst
@@ -27,16 +27,16 @@ action to redirect to this new url:
# config/routes.yaml
# load some routes - one should ultimately have the path "/app"
- AppBundle:
- resource: '@AppBundle/Controller/'
+ controllers:
+ resource: ../src/Controller/
type: annotation
prefix: /app
- # redirecting the root
- root:
+ # redirecting the homepage
+ homepage:
path: /
+ controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction
defaults:
- _controller: FrameworkBundle:Redirect:urlRedirect
path: /app
permanent: true
@@ -50,14 +50,14 @@ action to redirect to this new url:
http://symfony.com/schema/routing/routing-1.0.xsd">
-
-
-
- FrameworkBundle:Redirect:urlRedirect
+
+
+ Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction
/app
true
@@ -72,14 +72,14 @@ action to redirect to this new url:
$collection = new RouteCollection();
// load some routes - one should ultimately have the path "/app"
- $appRoutes = $loader->import("@AppBundle/Controller/", "annotation");
+ $appRoutes = $loader->import("../src/Controller/", "annotation");
$appRoutes->setPrefix('/app');
$collection->addCollection($appRoutes);
- // redirecting the root
- $collection->add('root', new Route('/', array(
- '_controller' => 'FrameworkBundle:Redirect:urlRedirect',
+ // redirecting the homepage
+ $collection->add('homepage', new Route('/', array(
+ '_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::urlRedirectAction',
'path' => '/app',
'permanent' => true,
)));
@@ -108,11 +108,10 @@ action:
# ...
- # redirecting the admin home
- root:
+ admin:
path: /wp-admin
+ controller: Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction
defaults:
- _controller: FrameworkBundle:Redirect:redirect
route: sonata_admin_dashboard
permanent: true
@@ -127,9 +126,8 @@ action:
-
-
- FrameworkBundle:Redirect:redirect
+
+ Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction
sonata_admin_dashboard
true
@@ -144,9 +142,8 @@ action:
$collection = new RouteCollection();
// ...
- // redirecting the root
- $collection->add('root', new Route('/wp-admin', array(
- '_controller' => 'FrameworkBundle:Redirect:redirect',
+ $collection->add('admin', new Route('/wp-admin', array(
+ '_controller' => 'Symfony\Bundle\FrameworkBundle\Controller\RedirectController::redirectAction',
'route' => 'sonata_admin_dashboard',
'permanent' => true,
)));
diff --git a/routing/redirect_trailing_slash.rst b/routing/redirect_trailing_slash.rst
index 0963938b6bb..99a9552ac0c 100644
--- a/routing/redirect_trailing_slash.rst
+++ b/routing/redirect_trailing_slash.rst
@@ -20,7 +20,7 @@ new URL with a 301 response status code::
class RedirectingController extends Controller
{
- public function removeTrailingSlashAction(Request $request)
+ public function removeTrailingSlash(Request $request)
{
$pathInfo = $request->getPathInfo();
$requestUri = $request->getRequestUri();
@@ -52,7 +52,7 @@ system, as explained below:
* @Route("/{url}", name="remove_trailing_slash",
* requirements={"url" = ".*\/$"}, methods={"GET"})
*/
- public function removeTrailingSlashAction(Request $request)
+ public function removeTrailingSlash(Request $request)
{
// ...
}
@@ -60,9 +60,10 @@ system, as explained below:
.. code-block:: yaml
+ # config/routes.yaml
remove_trailing_slash:
path: /{url}
- defaults: { _controller: AppBundle:Redirecting:removeTrailingSlash }
+ controller: App\Controller\RedirectingController::removeTrailingSlash
requirements:
url: .*/$
methods: [GET]
@@ -72,7 +73,7 @@ system, as explained below:
- AppBundle:Redirecting:removeTrailingSlash
+ App\Controller\RedirectingController::removeTrailingSlash
.*/$
@@ -88,7 +89,7 @@ system, as explained below:
new Route(
'/{url}',
array(
- '_controller' => 'AppBundle:Redirecting:removeTrailingSlash',
+ '_controller' => 'App\Controller\RedirectingController::removeTrailingSlash',
),
array(
'url' => '.*/$',
diff --git a/routing/requirements.rst b/routing/requirements.rst
index 4a6dd5a8592..7b75bd723a1 100644
--- a/routing/requirements.rst
+++ b/routing/requirements.rst
@@ -23,7 +23,7 @@ a routing ``{wildcard}`` to only match some regular expression:
/**
* @Route("/blog/{page}", name="blog_list", requirements={"page": "\d+"})
*/
- public function listAction($page)
+ public function list($page)
{
// ...
}
@@ -34,7 +34,7 @@ a routing ``{wildcard}`` to only match some regular expression:
# config/routes.yaml
blog_list:
path: /blog/{page}
- defaults: { _controller: AppBundle:Blog:list }
+ controller: App\Controller\BlogController::list
requirements:
page: '\d+'
@@ -48,7 +48,7 @@ a routing ``{wildcard}`` to only match some regular expression:
http://symfony.com/schema/routing/routing-1.0.xsd">
- AppBundle:Blog:list
+ App\Controller\BlogController::list
\d+
@@ -63,7 +63,7 @@ a routing ``{wildcard}`` to only match some regular expression:
$collection = new RouteCollection();
$collection->add('blog_list', new Route('/blog/{page}', array(
- '_controller' => 'AppBundle:Blog:list',
+ '_controller' => 'App\Controller\BlogController::list',
), array(
'page' => '\d+'
)));
@@ -101,7 +101,7 @@ URL:
* "_locale": "en|fr"
* })
*/
- public function homepageAction($_locale)
+ public function homepage($_locale)
{
}
}
@@ -110,8 +110,9 @@ URL:
# config/routes.yaml
homepage:
- path: /{_locale}
- defaults: { _controller: AppBundle:Main:homepage, _locale: en }
+ path: /{_locale}
+ controller: App\Controller\MainController::homepage
+ defaults: { _locale: en }
requirements:
_locale: en|fr
@@ -125,7 +126,7 @@ URL:
http://symfony.com/schema/routing/routing-1.0.xsd">
- AppBundle:Main:homepage
+ App\Controller\MainController::homepage
en
en|fr
@@ -139,7 +140,7 @@ URL:
$collection = new RouteCollection();
$collection->add('homepage', new Route('/{_locale}', array(
- '_controller' => 'AppBundle:Main:homepage',
+ '_controller' => 'App\Controller\MainController::homepage',
'_locale' => 'en',
), array(
'_locale' => 'en|fr',
@@ -200,7 +201,7 @@ accomplished with the following route configuration:
/**
* @Route("/api/posts/{id}", methods={"GET","HEAD"})
*/
- public function showAction($id)
+ public function show($id)
{
// ... return a JSON response with the post
}
@@ -208,7 +209,7 @@ accomplished with the following route configuration:
/**
* @Route("/api/posts/{id}", methods="PUT")
*/
- public function editAction($id)
+ public function edit($id)
{
// ... edit a post
}
@@ -218,14 +219,14 @@ accomplished with the following route configuration:
# config/routes.yaml
api_post_show:
- path: /api/posts/{id}
- defaults: { _controller: AppBundle:BlogApi:show }
- methods: [GET, HEAD]
+ path: /api/posts/{id}
+ controller: App\Controller\BlogApiController::show
+ methods: [GET, HEAD]
api_post_edit:
- path: /api/posts/{id}
- defaults: { _controller: AppBundle:BlogApi:edit }
- methods: [PUT]
+ path: /api/posts/{id}
+ controller: App\Controller\BlogApiController::edit
+ methods: [PUT]
.. code-block:: xml
@@ -237,11 +238,11 @@ accomplished with the following route configuration:
http://symfony.com/schema/routing/routing-1.0.xsd">
- AppBundle:BlogApi:show
+ App\Controller\BlogApiController::show
- AppBundle:BlogApi:edit
+ App\Controller\BlogApiController::edit
@@ -253,11 +254,11 @@ accomplished with the following route configuration:
$collection = new RouteCollection();
$collection->add('api_post_show', new Route('/api/posts/{id}', array(
- '_controller' => 'AppBundle:BlogApi:show',
+ '_controller' => 'App\Controller\BlogApiController::show',
), array(), array(), '', array(), array('GET', 'HEAD')));
$collection->add('api_post_edit', new Route('/api/posts/{id}', array(
- '_controller' => 'AppBundle:BlogApi:edit',
+ '_controller' => 'App\Controller\BlogApiController::edit',
), array(), array(), '', array(), array('PUT')));
return $collection;
diff --git a/routing/scheme.rst b/routing/scheme.rst
index 25308bedf06..2185db4463c 100644
--- a/routing/scheme.rst
+++ b/routing/scheme.rst
@@ -23,7 +23,7 @@ the URI scheme via schemes:
/**
* @Route("/secure", name="secure", schemes={"https"})
*/
- public function secureAction()
+ public function secure()
{
// ...
}
@@ -33,9 +33,9 @@ the URI scheme via schemes:
# config/routes.yaml
secure:
- path: /secure
- defaults: { _controller: AppBundle:Main:secure }
- schemes: [https]
+ path: /secure
+ controller: App\Controller\MainController::secure
+ schemes: [https]
.. code-block:: xml
@@ -47,7 +47,7 @@ the URI scheme via schemes:
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
- AppBundle:Main:secure
+ App\Controller\MainController::secure
@@ -59,7 +59,7 @@ the URI scheme via schemes:
$collection = new RouteCollection();
$collection->add('secure', new Route('/secure', array(
- '_controller' => 'AppBundle:Main:secure',
+ '_controller' => 'App\Controller\MainController::secure',
), array(), array(), '', array('https')));
return $collection;
diff --git a/routing/service_container_parameters.rst b/routing/service_container_parameters.rst
index a8c2e3e5a77..ffc6cf205f6 100644
--- a/routing/service_container_parameters.rst
+++ b/routing/service_container_parameters.rst
@@ -20,8 +20,8 @@ inside your routing configuration:
# config/routes.yaml
contact:
- path: /{_locale}/contact
- defaults: { _controller: AppBundle:Main:contact }
+ path: /{_locale}/contact
+ controller: App\Controller\MainController::contact
requirements:
_locale: '%app.locales%'
@@ -35,7 +35,7 @@ inside your routing configuration:
http://symfony.com/schema/routing/routing-1.0.xsd">
- AppBundle:Main:contact
+ App\Controller\MainController::contact
%app.locales%
@@ -48,7 +48,7 @@ inside your routing configuration:
$collection = new RouteCollection();
$collection->add('contact', new Route('/{_locale}/contact', array(
- '_controller' => 'AppBundle:Main:contact',
+ '_controller' => 'App\Controller\MainController::contact',
), array(
'_locale' => '%app.locales%',
)));
@@ -62,13 +62,13 @@ in your container:
.. code-block:: yaml
- # app/config/config.yml
+ # config/services.yaml
parameters:
app.locales: en|es
.. code-block:: xml
-
+
setParameter('app.locales', 'en|es');
You can also use a parameter to define your route path (or part of your
@@ -94,8 +94,8 @@ path):
# config/routes.yaml
some_route:
- path: /%app.route_prefix%/contact
- defaults: { _controller: AppBundle:Main:contact }
+ path: /%app.route_prefix%/contact
+ controller: App\Controller\MainController::contact
.. code-block:: xml
@@ -107,7 +107,7 @@ path):
http://symfony.com/schema/routing/routing-1.0.xsd">
- AppBundle:Main:contact
+ App\Controller\MainController::contact
@@ -119,7 +119,7 @@ path):
$collection = new RouteCollection();
$collection->add('some_route', new Route('/%app.route_prefix%/contact', array(
- '_controller' => 'AppBundle:Main:contact',
+ '_controller' => 'App\Controller\MainController::contact',
)));
return $collection;
diff --git a/routing/slash_in_parameter.rst b/routing/slash_in_parameter.rst
index b21d291d45f..a97d33135ec 100644
--- a/routing/slash_in_parameter.rst
+++ b/routing/slash_in_parameter.rst
@@ -33,7 +33,7 @@ a more permissive regular expression for it:
/**
* @Route("/share/{token}", name="share", requirements={"token"=".+"})
*/
- public function shareAction($token)
+ public function share($token)
{
// ...
}
@@ -41,14 +41,16 @@ a more permissive regular expression for it:
.. code-block:: yaml
+ # config/routes.yaml
share:
- path: /share/{token}
- defaults: { _controller: AppBundle:Default:share }
+ path: /share/{token}
+ controller: App\Controller\DefaultController::share
requirements:
token: .+
.. code-block:: xml
+
- AppBundle:Default:share
+ App\Controller\DefaultController::share
.+
.. code-block:: php
+ // config/routes.php
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\Route;
$collection = new RouteCollection();
$collection->add('share', new Route('/share/{token}', array(
- '_controller' => 'AppBundle:Default:share',
+ '_controller' => 'App\Controller\DefaultController::share',
), array(
'token' => '.+',
)));