Skip to content
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

docs: add about controllers namespace in routing #6451

Merged
merged 2 commits into from
Aug 30, 2022
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
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');