diff --git a/system/Config/BaseService.php b/system/Config/BaseService.php index 2f8df2a35420..cd770dc667ed 100644 --- a/system/Config/BaseService.php +++ b/system/Config/BaseService.php @@ -389,8 +389,15 @@ protected static function buildServicesCache(): void $locator = static::locator(); $files = $locator->search('Config/Services'); + $systemPath = static::autoloader()->getNamespace('CodeIgniter')[0]; + // Get instances of all service classes and cache them locally. foreach ($files as $file) { + // Does not search `CodeIgniter` namespace to prevent from loading twice. + if (str_starts_with($file, $systemPath)) { + continue; + } + $classname = $locator->findQualifiedNameFromPath($file); if ($classname === false) {