Skip to content

use use statement instead of namespace #11476

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
Show file tree
Hide file tree
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
8 changes: 3 additions & 5 deletions components/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ have to provide the name of a PHP file which returns a callable handling a :clas
This class allows to chain imports, collections or simple route definition calls::

// RouteProvider.php
namespace Symfony\Component\Routing\Loader\Configurator;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('route_name', '/foo')
Expand Down Expand Up @@ -444,9 +444,8 @@ routes with UTF-8 characters:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\DefaultController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('route1', '/category/{name}')
Expand Down Expand Up @@ -516,9 +515,8 @@ You can also include UTF-8 strings as routing requirements:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\DefaultController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('route2', '/category/{name}')
Expand Down
2 changes: 1 addition & 1 deletion controller/error_pages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ automatically when installing Twig support):
.. code-block:: php
// config/routes/dev/twig.php
namespace Symfony\Component\Routing\Loader\Configurator;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
return function (RoutingConfigurator $routes) {
$routes->import('@TwigBundle/Resources/config/routing/errors.xml')
Expand Down
5 changes: 2 additions & 3 deletions controller/service.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,12 @@ a service like: ``App\Controller\HelloController::index``:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\HelloController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('hello', '/hello')
->controller(['HelloController::class, 'index'])
->controller([HelloController::class, 'index'])
->methods(['GET'])
;
};
Expand Down
23 changes: 8 additions & 15 deletions routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,8 @@ Now you can configure the routes:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\BlogController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
// Matches /blog exactly
Expand Down Expand Up @@ -220,9 +219,8 @@ Symfony provides a handy way to declare localized routes without duplication.
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\CompanyController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('about_us', [
Expand Down Expand Up @@ -280,7 +278,7 @@ with a locale. This can be done by defining a different prefix for each locale
.. code-block:: php

// config/routes/annotations.php
namespace Symfony\Component\Routing\Loader\Configurator;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->import('../src/Controller/', 'annotation')
Expand Down Expand Up @@ -370,9 +368,8 @@ To fix this, add a *requirement* that the ``{page}`` wildcard can *only* match n
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\BlogController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('blog_list', '/blog/{page}')
Expand Down Expand Up @@ -440,9 +437,8 @@ concise, but it can decrease route readability when requirements are complex:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\BlogController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('blog_list', '/blog/{page<\d+>}')
Expand Down Expand Up @@ -521,9 +517,8 @@ So how can you make ``blog_list`` once again match when the user visits
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\BlogController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('blog_list', '/blog/{page}')
Expand Down Expand Up @@ -586,9 +581,8 @@ placeholder:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\BlogController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('blog_list', '/blog/{page<\d+>?1}')
Expand Down Expand Up @@ -690,9 +684,8 @@ With all of this in mind, check out this advanced example:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\ArticleController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('article_show', '/articles/{_locale}/{year}/{slug}.{_format}')
Expand Down
3 changes: 1 addition & 2 deletions routing/conditions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ define arbitrary matching logic, use the ``condition`` routing setting:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\DefaultController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('contact', '')
Expand Down
6 changes: 3 additions & 3 deletions routing/custom_route_loader.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Take these lines from the ``routes.yaml``:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->import('../src/Controller', 'annotation');
Expand Down Expand Up @@ -116,7 +116,7 @@ and configure the service and method to call:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->import('admin_route_loader::loadRoutes', 'service');
Expand Down Expand Up @@ -285,7 +285,7 @@ What remains to do is adding a few lines to the routing configuration:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->import('.', 'extra');
Expand Down
9 changes: 4 additions & 5 deletions routing/external_resources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ This can be done by importing routing resources from the main routing file:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
// loads routes from the given routing file stored in some bundle
Expand Down Expand Up @@ -128,7 +128,7 @@ instead of ``/blog/{slug}``):
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->import('../src/Controller/', 'annotation')
Expand Down Expand Up @@ -175,9 +175,8 @@ be prefixed with the string ``/site``.
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\ArticleController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->import('../src/Controller/', 'annotation')
Expand Down Expand Up @@ -244,7 +243,7 @@ a controller class or imported from a configuration file:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->import('../src/Controller/', 'annotation')
Expand Down
3 changes: 1 addition & 2 deletions routing/extra_information.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ to your controller, and as attributes of the ``Request`` object:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\BlogController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('blog', '/blog/{page}')
Expand Down
14 changes: 5 additions & 9 deletions routing/hostname_pattern.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ You can also match any route with the HTTP *host* of the incoming request.
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\MainController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('mobile_homepage', '/')
Expand Down Expand Up @@ -153,9 +152,8 @@ you can use placeholders in your hostname:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\MainController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('project_homepage', '/')
Expand Down Expand Up @@ -245,9 +243,8 @@ instance, if you want to match both ``m.example.com`` and
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\MainController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('mobile_homepage', '/')
Expand Down Expand Up @@ -344,9 +341,8 @@ instance, if you want to match both ``m.example.com`` and
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\MainController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('mobile_homepage', '/')
Expand Down Expand Up @@ -417,7 +413,7 @@ You can also set the host option on imported routes:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->import("@AcmeHelloBundle/Resources/config/routing.php")
Expand Down
9 changes: 3 additions & 6 deletions routing/optional_placeholders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,8 @@ the available blog posts for this imaginary blog application:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\BlogController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('blog', '/blog')
Expand Down Expand Up @@ -101,9 +100,8 @@ entries? Update the route to have a new ``{page}`` placeholder:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\BlogController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('blog', '/blog/{page}')
Expand Down Expand Up @@ -162,9 +160,8 @@ This is done by including it in the ``defaults`` collection:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\BlogController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('blog', '/blog/{page}')
Expand Down
6 changes: 2 additions & 4 deletions routing/redirect_in_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ action to redirect to this new url:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use Symfony\Bundle\FrameworkBundle\Controller\RedirectController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
// load some routes - one should ultimately have the path "/app"
Expand Down Expand Up @@ -140,9 +139,8 @@ action:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use Symfony\Bundle\FrameworkBundle\Controller\RedirectController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
// redirecting the homepage
Expand Down
9 changes: 3 additions & 6 deletions routing/requirements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ a routing ``{wildcard}`` to only match some regular expression:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\BlogController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('blog_list', '/blog/{page}')
Expand Down Expand Up @@ -134,9 +133,8 @@ URL:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\MainController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('homepage', '/{_locale}')
Expand Down Expand Up @@ -253,9 +251,8 @@ accomplished with the following route configuration:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\BlogApiController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('api_post_show', '/api/posts/{id}')
Expand Down
3 changes: 1 addition & 2 deletions routing/scheme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,8 @@ the URI scheme with the ``schemes`` setting:
.. code-block:: php

// config/routes.php
namespace Symfony\Component\Routing\Loader\Configurator;

use App\Controller\MainController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

return function (RoutingConfigurator $routes) {
$routes->add('secure', '/secure')
Expand Down
Loading