Skip to content

Commit aef22f7

Browse files
authored
Merge pull request #6309 from kenjis/fix-docs-modules.rst
docs: fix module namespace definition
2 parents e0cc1e1 + 1613476 commit aef22f7

3 files changed

Lines changed: 8 additions & 29 deletions

File tree

user_guide_src/source/general/modules.rst

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ directory in the main project root::
3030
/tests
3131
/writable
3232

33-
Open **app/Config/Autoload.php** and add the **Acme** namespace to the ``psr4`` array property:
33+
Open **app/Config/Autoload.php** and add the ``Acme\Blog`` namespace to the ``psr4`` array property:
3434

3535
.. literalinclude:: modules/001.php
3636

37-
Now that this is set up, we can access any file within the **acme** folder through the ``Acme`` namespace. This alone
37+
Now that this is set up, we can access any file within the **acme/Blog** folder through the ``Acme\Blog`` namespace. This alone
3838
takes care of 80% of what is needed for modules to work, so you should be sure to familiarize yourself with namespaces
3939
and become comfortable with their use. Several file types will be scanned for automatically through all defined namespaces - a crucial ingredient for working with modules.
4040

@@ -90,23 +90,18 @@ This is configured in the file **app/Config/Modules.php**.
9090

9191
The auto-discovery system works by scanning for particular directories and files within psr4 namespaces that have been defined in **Config/Autoload.php**.
9292

93-
To make auto-discovery work for our **Blog** namespace, we need to make one small adjustment.
94-
**Acme** needs to be changed to **Acme\\Blog** because each "module" within the namespace needs to be fully defined.
95-
96-
.. literalinclude:: modules/003.php
97-
98-
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**.
93+
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**.
9994

10095
Enable/Disable Discover
10196
=======================
10297

103-
You can turn on or off all auto-discovery in the system with the **$enabled** class variable. False will disable
98+
You can turn on or off all auto-discovery in the system with the ``$enabled`` class variable. False will disable
10499
all discovery, optimizing performance, but negating the special capabilities of your modules.
105100

106101
Specify Discovery Items
107102
=======================
108103

109-
With the **$aliases** option, you can specify which items are automatically discovered. If the item is not
104+
With the ``$aliases`` option, you can specify which items are automatically discovered. If the item is not
110105
present, then no auto-discovery will happen for that item, but the others in the array will still be discovered.
111106

112107
Discovery and Composer
@@ -173,12 +168,12 @@ with the ``new`` command:
173168

174169
.. literalinclude:: modules/008.php
175170

176-
Config files are automatically discovered whenever using the **config()** function that is always available.
171+
Config files are automatically discovered whenever using the ``config()`` function that is always available.
177172

178173
.. note:: We don't recommend you use the same short classname in modules.
179174
Modules that need to override or add to known configurations in **app/Config/** should use :ref:`registrars`.
180175

181-
.. note:: **config()** finds the file in **app/Config/** when there is a class with the same shortname,
176+
.. note:: ``config()`` finds the file in **app/Config/** when there is a class with the same shortname,
182177
even if you specify a fully qualified class name like ``config(\Acme\Blog\Config\Blog::class)``.
183178
This is because ``config()`` is a wrapper for the ``Factories`` class which uses ``preferApp`` by default. See :ref:`factories-options` for more information.
184179

user_guide_src/source/general/modules/001.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Autoload extends AutoloadConfig
99
public $psr4 = [
1010
APP_NAMESPACE => APPPATH, // For custom namespace
1111
'Config' => APPPATH . 'Config',
12-
'Acme' => ROOTPATH . 'acme',
12+
'Acme\Blog' => ROOTPATH . 'acme/Blog',
1313
];
1414

1515
// ...

user_guide_src/source/general/modules/003.php

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)