You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: user_guide_src/source/general/modules.rst
+7-12Lines changed: 7 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,11 +30,11 @@ directory in the main project root::
30
30
/tests
31
31
/writable
32
32
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:
34
34
35
35
.. literalinclude:: modules/001.php
36
36
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
38
38
takes care of 80% of what is needed for modules to work, so you should be sure to familiarize yourself with namespaces
39
39
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.
40
40
@@ -90,23 +90,18 @@ This is configured in the file **app/Config/Modules.php**.
90
90
91
91
The auto-discovery system works by scanning for particular directories and files within psr4 namespaces that have been defined in **Config/Autoload.php**.
92
92
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**.
99
94
100
95
Enable/Disable Discover
101
96
=======================
102
97
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
104
99
all discovery, optimizing performance, but negating the special capabilities of your modules.
105
100
106
101
Specify Discovery Items
107
102
=======================
108
103
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
110
105
present, then no auto-discovery will happen for that item, but the others in the array will still be discovered.
111
106
112
107
Discovery and Composer
@@ -173,12 +168,12 @@ with the ``new`` command:
173
168
174
169
.. literalinclude:: modules/008.php
175
170
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.
177
172
178
173
.. note:: We don't recommend you use the same short classname in modules.
179
174
Modules that need to override or add to known configurations in **app/Config/** should use :ref:`registrars`.
180
175
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,
182
177
even if you specify a fully qualified class name like ``config(\Acme\Blog\Config\Blog::class)``.
183
178
This is because ``config()`` is a wrapper for the ``Factories`` class which uses ``preferApp`` by default. See :ref:`factories-options` for more information.
0 commit comments