Skip to content

Commit a122ee6

Browse files
committed
docs: fix how to define namespaces
There is no real use case for `'Acme' => ROOTPATH . 'acme'`. Acme is a vendor namespace, but a module needs a module namespace for Auto-Discovery.
1 parent e0cc1e1 commit a122ee6

3 files changed

Lines changed: 4 additions & 25 deletions

File tree

user_guide_src/source/general/modules.rst

Lines changed: 3 additions & 8 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,12 +90,7 @@ 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
=======================

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)