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
+14-12Lines changed: 14 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,9 +11,9 @@ language files, etc. Modules may contain as few, or as many, of these as you lik
11
11
:local:
12
12
:depth: 2
13
13
14
-
==========
14
+
**********
15
15
Namespaces
16
-
==========
16
+
**********
17
17
18
18
The core element of the modules functionality comes from the :doc:`PSR-4 compatible autoloading <../concepts/autoloader>`
19
19
that CodeIgniter uses. While any code can use the PSR-4 autoloader and namespaces, the primary way to take full advantage of
@@ -58,9 +58,9 @@ Of course, there is nothing forcing you to use this exact structure, and you sho
58
58
best suits your module, leaving out directories you don't need, creating new directories for Entities, Interfaces,
59
59
or Repositories, etc.
60
60
61
-
===========================
61
+
***************************
62
62
Autoloading Non-class Files
63
-
===========================
63
+
***************************
64
64
65
65
More often than not that your module will not contain only PHP classes but also others like procedural
66
66
functions, bootstrapping files, module constants files, etc. which are not normally loaded the way classes
@@ -73,31 +73,33 @@ your classes. All we need to do is provide the list of paths to those files and
73
73
74
74
.. literalinclude:: modules/002.php
75
75
76
-
==============
76
+
.. _auto-discovery:
77
+
78
+
**************
77
79
Auto-Discovery
78
-
==============
80
+
**************
79
81
80
82
Many times, you will need to specify the full namespace to files you want to include, but CodeIgniter can be
81
83
configured to make integrating modules into your applications simpler by automatically discovering many different
82
84
file types, including:
83
85
84
86
- :doc:`Events <../extending/events>`
85
87
- :doc:`Filters <../incoming/filters>`
86
-
- :doc:`Registrars <./configuration>`
88
+
- :ref:`registrars`
87
89
- :doc:`Route files <../incoming/routing>`
88
90
- :doc:`Services <../concepts/services>`
89
91
90
92
This is configured in the file **app/Config/Modules.php**.
91
93
92
-
The auto-discovery system works by scanning for particular directories and files within psr4 namespaces that have been defined in **Config/Autoload.php**.
94
+
The auto-discovery system works by scanning for particular directories and files within psr4 namespaces that have been defined in **Config/Autoload.php** and Composer packages.
93
95
94
-
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**.
96
+
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**.
95
97
96
98
Enable/Disable Discover
97
99
=======================
98
100
99
101
You can turn on or off all auto-discovery in the system with the ``$enabled`` class variable. False will disable
100
-
all discovery, optimizing performance, but negating the special capabilities of your modules.
102
+
all discovery, optimizing performance, but negating the special capabilities of your modules and Composer packages.
101
103
102
104
Specify Discovery Items
103
105
=======================
@@ -134,9 +136,9 @@ by editing the ``$discoverInComposer`` variable in **app/Config/Modules.php**:
134
136
135
137
.. literalinclude:: modules/004.php
136
138
137
-
==================
139
+
******************
138
140
Working with Files
139
-
==================
141
+
******************
140
142
141
143
This section will take a look at each of the file types (controllers, views, language files, etc) and how they can
142
144
be used within the module. Some of this information is described in more detail in the relevant location of the user
0 commit comments