File tree 4 files changed +21
-28
lines changed
user_guide_src/source/concepts
4 files changed +21
-28
lines changed Original file line number Diff line number Diff line change @@ -20,4 +20,13 @@ class Optimize
20
20
* @see https://codeigniter.com/user_guide/concepts/factories.html#config-caching
21
21
*/
22
22
public bool $ configCacheEnabled = false ;
23
+
24
+ /**
25
+ * --------------------------------------------------------------------------
26
+ * Config Caching
27
+ * --------------------------------------------------------------------------
28
+ *
29
+ * @see https://codeigniter.com/user_guide/concepts/autoloader.html#file-locator-caching
30
+ */
31
+ public bool $ locatorCacheEnabled = false ;
23
32
}
Original file line number Diff line number Diff line change 15
15
16
16
use CodeIgniter \Autoloader \Autoloader ;
17
17
use CodeIgniter \Autoloader \FileLocator ;
18
+ use CodeIgniter \Autoloader \FileLocatorCached ;
18
19
use CodeIgniter \Autoloader \FileLocatorInterface ;
19
20
use CodeIgniter \Cache \CacheInterface ;
20
21
use CodeIgniter \Cache \ResponseCache ;
71
72
use Config \Images ;
72
73
use Config \Migrations ;
73
74
use Config \Modules ;
75
+ use Config \Optimize ;
74
76
use Config \Pager as ConfigPager ;
75
77
use Config \Services as AppServices ;
76
78
use Config \Toolbar as ConfigToolbar ;
@@ -235,7 +237,14 @@ public static function locator(bool $getShared = true)
235
237
{
236
238
if ($ getShared ) {
237
239
if (empty (static ::$ instances ['locator ' ])) {
238
- static ::$ instances ['locator ' ] = new FileLocator (static ::autoloader ());
240
+ $ cacheEnabled = class_exists (Optimize::class)
241
+ && (new Optimize ())->locatorCacheEnabled ;
242
+
243
+ if ($ cacheEnabled ) {
244
+ static ::$ instances ['locator ' ] = new FileLocatorCached (new FileLocator (static ::autoloader ()));
245
+ } else {
246
+ static ::$ instances ['locator ' ] = new FileLocator (static ::autoloader ());
247
+ }
239
248
}
240
249
241
250
return static ::$ mocks ['locator ' ] ?? static ::$ instances ['locator ' ];
Original file line number Diff line number Diff line change @@ -190,6 +190,6 @@ Or simply delete the **writable/cache/FileLocatorCache** file.
190
190
How to Enable FileLocator Caching
191
191
=================================
192
192
193
- Add the following code in **app/Config/Services .php **:
193
+ Set the following property to `` true `` in **app/Config/Optimize .php **: :
194
194
195
- .. literalinclude :: autoloader/004.php
195
+ public bool $locatorCacheEnabled = true;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments