Doctrine ORM Toolkit for PHP and CodeIgniter 4¶
Standalone Doctrine ORM toolkit for PHP 8.5, with an optional CodeIgniter 4 adapter. Configure ORM, caching and logging explicitly, or integrate with CI4's services, database groups, toolbar and Spark.
Version 6.0: breaking changes
Existing application imports and constructors require migration. See Installation for Packagist releases and local development installations.
Choose a package¶
| Package | Included |
|---|---|
daycry/doctrine |
Framework-independent ORM setup, DataTables, PSR-6 caching, PSR-3 query logging, named managers and console tools |
daycry/doctrine-codeigniter4 |
Core plus CI4 config/services, database/cache translation, helpers, toolbar and Spark |
The core requires PHP ^8.5, ORM ^3.7, DBAL ^4.5, Symfony Cache/Console ^8 and DoctrineExtensions ^1.5. The adapter additionally requires CodeIgniter ^4.7.
Standalone quick start¶
After installing the core:
require __DIR__ . '/vendor/autoload.php';
$config = new \Daycry\Doctrine\Configuration();
$config->connection = ['driver' => 'pdo_sqlite', 'memory' => true];
$doctrine = new \Daycry\Doctrine\Doctrine($config);
echo $doctrine->getEm()->getConnection()->fetchOne('SELECT 1');
Set existing mapping directories on $config->entities before constructing the
manager to use mapped entities. See standalone usage.
CodeIgniter quick start¶
After installing the adapter:
Configure connections in Config\Database, caches in Config\Cache and ORM
overrides in the published Config\Doctrine. See CI4 usage.
Explore the toolkit¶
-
DataTables
ORM QueryBuilder input, array request parameters, safe filter operators, bounded pages and WindowPage results. Works without an HTTP framework.
-
Caching
Inject PSR-6 pools into the core or use CI4 backend wiring. Cache-aside and SLC support explicit lifetimes, invalidation and optional statistics.
-
:material-database-multiple:{ .lg .middle } Named managers
Lazy ManagerRegistry factories in standalone code and case-sensitive database group services in the adapter.
-
Configuration
Attributes/XML, custom types and DQL functions, filters, listeners/subscribers, DBAL middlewares and repository classes.
-
Logging and toolbar
PSR-3 query logging with a slow-query threshold in the core. The optional CI4 toolbar displays debug queries and SLC counters.
-
Operational tools
Standalone Symfony Console, CI4 Spark, readiness diagnostics and metadata warmup. Schema operations use the native ORM commands.