- Package:
daycry/doctrineprovides Doctrine integration for CodeIgniter 4. - Autoload: When installing manually, register the
Daycry\Doctrinenamespace inapp/Config/Autoload.php.
Use Composer to install the package:
composer require daycry/doctrine
Download this repository and enable it by editing app/Config/Autoload.php and adding the Daycry\Doctrine namespace to the $psr4 array. For example, if you copied it into app/ThirdParty:
$psr4 = [
'Config' => APPPATH . 'Config',
APP_NAMESPACE => APPPATH,
'App' => APPPATH,
'Daycry\Doctrine' => APPPATH .'ThirdParty/doctrine/src',
];- Prefer Composer installation to ensure dependencies and autoloading are managed correctly.
- After installation, run
php spark doctrine:publishto publish configuration files.
To view Doctrine queries in the CodeIgniter Debug Toolbar:
- Register the collector in
app/Config/Toolbar.php:public $collectors = [ // ... other collectors ... \Daycry\Doctrine\Debug\Toolbar\Collectors\DoctrineCollector::class, ];
- Instantiate Doctrine (service, helper, or direct). Middleware auto-registers.
- Optional (development): reset Second-Level Cache counters per request by adding the filter in
app/Config/Filters.php:public array $globals = [ 'before' => [ // ... other filters ... \Daycry\Doctrine\Debug\Filters\DoctrineSlcReset::class, ], 'after' => [], ];
If you enable Config\Doctrine::$secondLevelCacheStatistics = true, the Doctrine panel shows a badge SLC:hits/misses/puts (ratio%) and a small statistics table above the queries.