Skip to content

Commit 01c55b0

Browse files
authored
Merge pull request #5281 from kenjis/fix-modules.rst
docs: improve modules.rst
2 parents 031e4b8 + a5e9aae commit 01c55b0

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

user_guide_src/source/general/modules.rst

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,17 @@ This is configured in the file **app/Config/Modules.php**.
101101
The auto-discovery system works by scanning for particular directories and files within psr4 namespaces that have been defined in **Config/Autoload.php**.
102102

103103
To make auto-discovery work for our **Blog** namespace, we need to make one small adjustment.
104-
**Acme** needs to be changed to **Acme\\Blog** because each "module" within the namespace needs to be fully defined. Once your module folder path is defined, the discovery process would look for discoverable items on that path and should, for example, find the routes file at **/acme/Blog/Config/Routes.php**.
104+
**Acme** needs to be changed to **Acme\\Blog** because each "module" within the namespace needs to be fully defined.
105+
106+
::
107+
108+
public $psr4 = [
109+
APP_NAMESPACE => APPPATH, // For custom namespace
110+
'Config' => APPPATH . 'Config',
111+
'Acme\Blog' => ROOTPATH . 'acme/Blog', // Change
112+
];
113+
114+
Once your module folder path is defined, the discovery process would look for discoverable items on that path and should, for example, find the routes file at **/acme/Blog/Config/Routes.php**.
105115

106116
Enable/Disable Discover
107117
=======================
@@ -143,6 +153,19 @@ the **Modules** config file, described above.
143153
.. note:: Since the files are being included into the current scope, the ``$routes`` instance is already defined for you.
144154
It will cause errors if you attempt to redefine that class.
145155

156+
Filters
157+
=======
158+
159+
By default, :doc:`filters </incoming/filters>` are automatically scanned for within modules.
160+
It can be turned off in the **Modules** config file, described above.
161+
162+
.. note:: Since the files are being included into the current scope, the ``$filters`` instance is already defined for you.
163+
It will cause errors if you attempt to redefine that class.
164+
165+
In the module's **Config/Filters.php** file, you need to define the aliases of the filters you use.::
166+
167+
$filters->aliases['menus'] = MenusFilter::class;
168+
146169
Controllers
147170
===========
148171

0 commit comments

Comments
 (0)