sympress / doctrine-bundle
Native Doctrine ORM, DBAL and Symfony Doctrine bridge integration for SymPress.
Requires
- php: ^8.5
- doctrine/dbal: ^4.3
- doctrine/doctrine-bundle: ^3.3
- doctrine/doctrine-migrations-bundle: ^4.0
- doctrine/orm: ^3.7
- symfony/doctrine-bridge: ^8.1
- sympress/framework-bundle: ^1.0.9
- sympress/kernel: ^1.1.14
Requires (Dev)
- phpstan/phpstan-doctrine: ^2.0
- symfony/doctrine-messenger: ^8.1
- symfony/form: ^8.1
- symfony/maker-bundle: ^1.0
- symfony/property-info: ^8.1
- symfony/security-bundle: ^8.1
- symfony/serializer: ^8.1
- symfony/uid: ^8.1
- symfony/validator: ^8.1
- sympress/qa: ^0.1.2
Suggests
- ext-pdo_mysql: MySQL and MariaDB connections.
- ext-pdo_pgsql: PostgreSQL connections.
- ext-pdo_sqlite: SQLite connections.
- symfony/doctrine-messenger: Doctrine Messenger transports and transaction middleware.
- symfony/form: EntityType and Doctrine-backed form choices.
- symfony/maker-bundle: Development-time entity and migration generation.
- symfony/security-bundle: Doctrine entity user providers for separately configured security firewalls.
- symfony/validator: UniqueEntity and Doctrine-aware validation.
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-16 14:36:07 UTC
README
Native Doctrine ORM and DBAL integration for the SymPress ecosystem. Uses the
original DoctrineBundle, DoctrineMigrationsBundle and Symfony Doctrine Bridge.
Requires PHP 8.5, SymPress Kernel >= 1.1.10 and Framework Bundle >= 1.0.7.
Entities and persistence do not depend on wpdb or WordPress hooks. The package
has no dependency on another SymPress persistence package.
Installation
Install the public package from Packagist in the consuming application's root:
composer require sympress/doctrine-bundle:^1.0.1
The SymPress kernel discovers the bundle through extra.kernel and registers its
Framework and Migrations requirements. Symfony Flex is not required.
Configuration and use
Use native doctrine and doctrine_migrations configuration in your application's
kernel-loaded config directory. Configure entities explicitly by PSR-4 namespace
and path. Use Doctrine\ORM\Mapping attributes, inject
Doctrine\ORM\EntityManagerInterface into application services, and use
Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository for
service-backed repositories. Existing Symfony Doctrine documentation applies.
The complete configuration example and usage are maintained in
examples/.
Optional Symfony integrations require their own components: Form, Validator, SecurityBundle, MakerBundle or Doctrine Messenger. This package preserves the upstream integration; it does not install a WordPress authentication layer.
mysqli inside WordPress
WordPress' wpdb sets mysqli_report(MYSQLI_REPORT_OFF) for the whole PHP
process, while DBAL's mysqli driver relies on mysqli exceptions. The bundle
registers a DBAL middleware that runs each Doctrine call on a mysqli
connection in strict reporting mode and restores the previous mode afterwards,
so DBAL raises its usual exceptions and wpdb keeps its behavior. pdo_mysql
connections are not affected.
Database ownership
Use Doctrine for application-owned entities and tables. On every connection the
bundle hides all tables that start with the WordPress table prefix from Doctrine's
schema tools, so doctrine:schema:update, doctrine:migrations:diff and the
fixtures purger never touch wp_posts, wp_users or multisite tables such as
wp_2_posts. The prefix comes from $wpdb->base_prefix, then the $table_prefix
global, then DB_TABLE_PREFIX (environment variable or constant). Without any of
them, schema tools refuse to run instead of guessing. This cannot be turned off.
Do not start application table names with the WordPress prefix: migration diffs
and fixture purges skip them. A configured schema_filter still applies on top;
keep one that admits only your own tables and the migrations metadata table.
doctrine:migrations:diff --filter-expression replaces all connection filters for
that run, including this one. Review generated migrations and execute them during
deployment. Bundle boot never applies schema changes.
Separate wpdb and DBAL connections do not share a transaction. Modify WordPress
and WooCommerce-owned data through their APIs. Tenant selection and work-unit
reset belong to the application, not an implicit WordPress blog switch.
Development
composer install
composer qa
DOCTRINE_TEST_DATABASE_URL='mysql://user:password@127.0.0.1/sympress_doctrine_test' composer tests:database
The default suite verifies the real SymPress kernel and original Doctrine stack against SQLite. Hosted CI also runs disposable MariaDB and PostgreSQL tests. Development dependencies are locked; consumers resolve stable runtime ranges.
License: GPL-2.0-or-later. Upstream dependencies retain their original licenses.