daycry / doctrine
Standalone Doctrine ORM toolkit with an optional CodeIgniter 4 adapter
Requires
- php: ^8.5
- beberlei/doctrineextensions: ^1.5
- doctrine/dbal: ^4.5
- doctrine/event-manager: ^2
- doctrine/orm: ^3.7
- psr/cache: ^3
- psr/log: ^3
- scienta/doctrine-json-functions: ^6.5
- symfony/cache: ^8
- symfony/console: ^8
Requires (Dev)
- codeigniter/phpstan-codeigniter: ^1.6
- codeigniter4/devkit: ^1
- codeigniter4/framework: ^4.7
- ergebnis/composer-normalize: ^2.28
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan-strict-rules: ^2
- phpunit/phpcov: ^10
- rector/rector: ^2.8
- roave/security-advisories: dev-latest
- vimeo/psalm: ^6.20
Suggests
- ext-memcached: Required for the Memcached cache backend
- ext-redis: Required for the Redis cache backend
- daycry/doctrine-codeigniter4: CodeIgniter 4 services, configuration, Spark commands and toolbar integration
- doctrine/migrations: Versioned schema migrations integration for the Doctrine ORM CLI (php cli-config.php / spark doctrine:*)
Provides
None
Conflicts
None
Replaces
None
- dev-master
- v6.0.0
- v5.1.0
- v5.0.0
- v4.2.0
- v4.1.14
- v4.1.13
- v4.1.12
- v4.1.11
- v4.1.10
- v4.1.9
- v4.1.8
- v4.1.7
- v4.1.6
- v4.1.5
- v4.1.4
- v4.1.3
- v4.1.2
- v4.1.1
- v4.0.1
- v4.0.0
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v2.0.2
- v2.0.1
- v2.0.0
- v1.4.5
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.9
- v1.3.8
- v1.3.7
- v1.3.6
- v1.3.5
- v1.3.4
- v1.3.3
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.0
- v1.1.9
- v1.1.8
- v1.1.7
- v1.1.6
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.1
- v1.0.0
- dev-fix/issue-21-toolbar-collector
- dev-feat/standalone-core
- dev-development
- dev-docs/readme-pages-link
- dev-feat/audit-improvements
- dev-refactor/audit-and-docs
This package is auto-updated.
Last update: 2026-10-29 14:37:03 UTC
README
Doctrine ORM Toolkit for PHP and CodeIgniter 4
Standalone Doctrine ORM toolkit for PHP 8.5, with an optional CodeIgniter 4 adapter.
📖 Documentation: https://daycry.github.io/doctrine/
Packages and release status
This documentation describes version 6.0, with breaking API and namespace changes. See the migration guide before upgrading. Published package badges can refer to an earlier release.
| Package | Role |
|---|---|
daycry/doctrine |
Standalone core: ORM configuration, DataTables, PSR-6 caching, PSR-3 logging, named managers and console tools |
daycry/doctrine-codeigniter4 |
Optional adapter: CI4 configuration/services, database groups, cache backends, helpers, toolbar and Spark |
The core has no CodeIgniter runtime dependency. Both packages require PHP ^8.5; the core uses ORM ^3.7, DBAL ^4.5, Symfony Cache/Console ^8 and DoctrineExtensions ^1.5. The adapter also requires CI4 ^4.7.
Installation
Choose one package from Packagist:
# Standalone core composer require daycry/doctrine:^6.0 # CodeIgniter application: installs the core and framework too composer require daycry/doctrine-codeigniter4:^6.0
Local path repositories are also available for development.
Standalone quick start
require __DIR__ . '/vendor/autoload.php'; use Daycry\Doctrine\Configuration; use Daycry\Doctrine\Doctrine; $config = new Configuration(); $config->connection = ['driver' => 'pdo_sqlite', 'memory' => true]; $doctrine = new Doctrine($config); echo $doctrine->getEm()->getConnection()->fetchOne('SELECT 1');
For mapped entities, assign existing directories to $config->entities before
constructing Doctrine. Native lazy objects are always enabled; no proxy files are
generated. See standalone usage for persistent cache pools,
logging, named managers and lifecycle handling.
CodeIgniter quick start
php spark doctrine:publish
The publisher writes app/Config/Doctrine.php and cli-config.php. The config
extends Daycry\Doctrine\CodeIgniter4\Config\Doctrine and contains application
overrides. Configure connections through Config\Database and caches through
Config\Cache.
$doctrine = service('doctrine'); $em = $doctrine->getEm(); // An explicitly named database group: $reporting = \Daycry\Doctrine\CodeIgniter4\Config\Services::doctrine(true, 'reporting');
See CI4 usage for shared services, helpers and group resets, and debug toolbar for collector/filter registration.
DataTables
The Builder works in either package and accepts an ORM QueryBuilder and a request array. It does not require an HTTP framework:
use Daycry\Doctrine\DataTables\Builder; $response = Builder::create() ->withQueryBuilder($queryBuilder) ->withColumnAliases(['id' => 'p.id', 'name' => 'p.name']) ->withSearchableColumns(['p.name']) ->withRequestParams($requestParams) ->getResponse();
The query must use the p alias in this example. The response contains draw,
recordsTotal, recordsFiltered and data. The default page cap is 200;
length=-1 is clamped to it, and the cap must remain positive.
Use getPage() for a WindowPage with items and filtered total.
See Builder API and search operators.
Caching, logging and extension points
- Inject
CachePoolsinto the core for query/result/metadata/SLC storage; defaults are independent process-local ArrayAdapters. The CI4 adapter creates pools from its framework backend. - Use
Cache\CacheAsidedirectly in standalone code. The adapter also autoloads the namespacedDaycry\Doctrine\CodeIgniter4\Helpers\getFromCacheOrQueryfunction. - Enable SLC, statistics, custom DBAL types, SQL filters, event listeners/subscribers, DBAL middlewares and a default repository through configuration.
- Query logging accepts a PSR-3 logger and a slow-query threshold. The core requires an injected logger; the adapter resolves CI4's logger service.
See SLC configuration and cache statistics.
Console
The standalone console loads an application bootstrap returning Doctrine or a ManagerRegistry. Spark commands use the CI4 adapter:
php vendor/bin/daycry-doctrine doctrine-bootstrap.php orm:info php vendor/bin/daycry-doctrine doctrine-bootstrap.php doctrine:doctor --json php vendor/bin/daycry-doctrine doctrine-bootstrap.php doctrine:cache:warmup php spark doctrine:doctor --group reporting --json php spark doctrine:cache:warmup --group reporting
Doctor and warmup do not change the schema. They report connection/mapping/cache failures through nonzero exit codes. The console guide explains the bootstrap, named managers and native ORM commands.
Development
composer install
composer test
php vendor/bin/phpunit -c phpunit.standalone.xml.dist --no-coverage
composer analyze
composer cs
python -m mkdocs build --strict --site-dir build/docs
The integration suite needs its configured test database and optional cache services. The native core suite uses SQLite and a separate bootstrap. CI also installs isolated consumers to verify the core without CI4 installed and the adapter's framework discovery. See validation records.
Documentation
- Installation
- Standalone core
- Configuration
- CI4 services and helpers
- DataTables
- Console commands
- 6.x migration
- Changelog
License
MIT.