Skip to content

Commit

Permalink
Merge pull request #6451 from kenjis/fix-docs-routing-namespace
Browse files Browse the repository at this point in the history
docs: add about controllers namespace in routing
  • Loading branch information
kenjis authored Aug 30, 2022
2 parents cd4bc83 + e046890 commit a51b07c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
21 changes: 20 additions & 1 deletion user_guide_src/source/incoming/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,23 @@ You can supply multiple verbs that a route should match by passing them in as an

.. literalinclude:: routing/004.php

Controller's Namespace
======================

If a controller name is stated without beginning with ``\``, the :ref:`routing-default-namespace` will be prepended:

.. literalinclude:: routing/063.php

If you put ``\`` at the beginning, it is treated as a fully qualified class name:

.. literalinclude:: routing/064.php

You can also specify the namespace with the ``namespace`` option:

.. literalinclude:: routing/038.php

See :ref:`assigning-namespace` for details.

Placeholders
============

Expand Down Expand Up @@ -394,7 +411,7 @@ You specify an array for the filter value:
Assigning Namespace
-------------------

While a default namespace will be prepended to the generated controllers (see below), you can also specify
While a :ref:`routing-default-namespace` will be prepended to the generated controllers, you can also specify
a different namespace to be used in any options array, with the ``namespace`` option. The value should be the
namespace you want modified:

Expand Down Expand Up @@ -480,6 +497,8 @@ Routes Configuration Options
The RoutesCollection class provides several options that affect all routes, and can be modified to meet your
application's needs. These options are available at the top of **app/Config/Routes.php**.

.. _routing-default-namespace:

Default Namespace
=================

Expand Down
4 changes: 4 additions & 0 deletions user_guide_src/source/incoming/routing/063.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

// Routes to \App\Controllers\Api\Users::update()
$routes->post('api/users', 'Api\Users::update');
4 changes: 4 additions & 0 deletions user_guide_src/source/incoming/routing/064.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php

// Routes to \Acme\Blog\Controllers\Home::list()
$routes->get('blog', '\Acme\Blog\Controllers\Home::list');

0 comments on commit a51b07c

Please sign in to comment.