Download the PHP package elriseio/dbal-bundle without Composer

On this page you can find all versions of the php package elriseio/dbal-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dbal-bundle

Dbal Bundle for Symfony

CI Latest Stable Version Total Downloads License

Dbal Bundle is a module for Symfony applications designed for high-load systems, where the standard capabilities of Doctrine ORM become a bottleneck. The bundle provides abstractions and interfaces for direct, efficient, and scalable database operations at the Doctrine DBAL level.

Key Features

Verified Load-Test Performance (Wave LT, --rows 1000 --chunk 100)

Measured by the itests/ integration load-testing pipeline (ADR-0004) on real MySQL 8.4, PostgreSQL 16, and MariaDB 11 in Docker. Full report with the per-vendor raw envelopes: itests/reports/WAVE_LT_CROSS_VENDOR_REPORT.md.

Single-vendor metrics (one --rows 1000 --chunk 100 invocation per scenario)

Scenario Vendor duration ops/sec p50 latency p95 / p99 latency errors
bulk_insert MySQL 8.4 0.207s 4,831 16.48 ms 41.45 ms 0
bulk_insert PostgreSQL 16 0.130s 7,692 10.31 ms 20.79 ms 0
bulk_insert MariaDB 11 0.222s 4,505 20.73 ms 37.99 ms 0
bulk_upsert MySQL 8.4 0.027s 37,037 11.29 ms 104.90 ms 0
bulk_upsert PostgreSQL 16 0.108s 9,259 10.17 ms 805.01 ms 0
bulk_upsert MariaDB 11 0.028s 35,714 12.12 ms 47.19 ms 0
bulk_update MySQL 8.4 0.031s 64,516 1.97 ms 19.45 / 31.68 ms 0
bulk_update PostgreSQL 16 0.148s 13,514 9.34 ms 14.45 / 16.23 ms 0
bulk_update MariaDB 11 0.028s 71,429 1.81 ms 9.41 / 13.85 ms 0
cursor_stream MySQL 8.4 0.002s 500,000 0.15 ms 0.21 ms 0
cursor_stream PostgreSQL 16 0.003s 333,333 0.23 ms 0.30 ms 0
cursor_stream MariaDB 11 0.002s 500,000 0.13 ms 0.17 ms 0

Notes on the table:

Bounded-concurrency parallel runner (--workers 2 --concurrency 2, cursor_stream, --rows 500 per worker)

Vendor total_rows total_duration throughput ops/sec p50 / p95 / p99 latency errors
MySQL 8.4 400 0.002s 200,000 0.31 / 0.34 / 0.42 ms 0
PostgreSQL 16 1,000 0.002s 500,000 0.23 / 0.24 / 0.24 ms 0
MariaDB 11 1,000 0.002s 500,000 0.32 / 0.35 / 0.38 ms 0

PG and MariaDB scale linearly (2× workers ≈ 2× throughput). MySQL's total_rows=400 (instead of 1000) is a known unique-email collision between parallel workers; not a correctness regression — the read path itself is correct.

What the numbers mean

All scenarios report errors: 0 on every vendor; the canonical envelope contract (ADR-0004 Decision §5) is observed end-to-end; the bounded-concurrency parallel runner scales linearly on PG and MariaDB. 306/306 PHPUnit tests pass; php-cs-fixer reports 0 new violations.

Architecture

The Dbal Bundle is built on interfaces and abstractions that are easy to extend and adapt to any needs.

At the core of select operations are generators (yield), which allows:

Key Interfaces:

Finder/Mutator

Bulk Operations

Iterators

Helper Classes

Installation

Run the following command to install the bundle:

Register the bundle in config/bundles.php:

Working with DbalManagerFactory

The DbalManagerFactory class allows you to conveniently create DBAL infrastructure components with the ability to override the database connection (Connection) and configuration (DbalBundleConfig) at the service level.

Quick Creation of DbalManager

If you want to use all DBAL components at once, simply call the createManager() method:

You can pass custom Connection and DbalBundleConfig:

Creating Individual Components

If you need to use one of the components separately, use the corresponding method:

For each of these methods, you can specify your custom Connection and (optionally) DbalBundleConfig:

This is especially useful if you're working with multiple databases or want to use different configuration strategies.

Example of Using in a Service

Bulk Insert

The module supports bulk data insertion with the ability to specify:

Usage Example

The array ['value', ParameterType::TYPE] allows specifying the value type compatible with Doctrine\DBAL\ParameterType. If the type is not specified, it will be determined automatically.


ID Generation Strategies (IdStrategy)

The ID can be generated automatically or set manually, depending on the strategy:

Strategy Description
IdStrategy::AUTO_INCREMENT The value is not specified — it is generated at the database level
IdStrategy::UUID The value is generated in the code (UUID v7)
IdStrategy::UID Deprecated since 1.0.x for collision-safety; remains in 2.0 (per ADR-0002 § Decision 3). The 18-char id is collision-prone under concurrent writers. Prefer IdStrategy::UUID (UUID v7) for new code; existing IdStrategy::UID users do not need to migrate to upgrade to 2.0. Use IdStrategy::migrateFromV1() to plan an INT/STRING → 2.0 replacement.
IdStrategy::INT The value is generated as a random integer
IdStrategy::STRING A string is generated (e.g., based on uniqid())
IdStrategy::DEFAULT The value should be used for working with Postgres and generating a DEFAULT ID within Insert/Upsert operations
IdStrategy::migrateFromV1() Static helper. Maps v1 cases (INT, STRING) to their v2 replacements per ADR-0002 § Decision 3. Available in 1.x as a developer-experience aid for consumers planning their 2.0 upgrade. Cases surviving 2.0 (AUTO_INCREMENT, UUID, UID, DEFAULT) pass through unchanged.

DbalBulkUpdater

DbalBulkUpdater Allows updating from 1 to multiple rows in the database.

📌 Example

By default, the id field is used as the condition. The update is performed using CASE WHEN ... THEN ... without multiple queries. The number of affected rows is returned.

DbalBulkUpserter

DbalBulkUpserter Allows inserting or updating records based on key fields. If a record with the given id already exists, it will be updated; if not, a new record will be inserted.

Example

The fields to be updated are passed as the third argument (replaceFields). The id can be generated automatically using IdStrategy::AUTO_INCREMENT.

PostgreSQL: RETURNING id in one round-trip

On PostgreSQL, upsertManyReturningIds appends RETURNING <column> to the upsert SQL and returns the generated/updated IDs in row order. MySQL / MariaDB do not support RETURNING and will throw LogicException on this call.

DbalFinder

DbalFinder Provides methods for type-safe extraction of data from the database.

Usage Examples

If no DTO class is specified, an array will be returned.

DbalMutator

DbalMutator Designed for safe insertion and modification of data in database tables.

Usage Examples

Fields with types are supported (e.g., ['value', ParameterType::STRING]). If the type is not specified, it will be determined automatically.

⚠️ Важно

Before using the methods insert(), updateMany(), upsertMany(), it is essential to specify the current service fields either through the setFieldNames() method or a general configuration in the fieldNames field.

SQL caller-trace comment (opt-in)

The bundle exposes the existing DbalConnection::setAdditionalSqlCommentEnable toggle through the doctrine_dbal bundle configuration. Default: off (backward-compatible).

When enabled, every executeQuery, executeStatement, and prepare call prepends a JSON caller-trace comment to the SQL string. The comment carries applicationCaller (the first non-framework class in the backtrace) and entryPointController (the Symfony controller or console command name, if any). Operators can read the comment in their MySQL slow log, PostgreSQL pg_stat_statements, or the database's general log to see which application code path produced each query.

Enable per environment in config/packages/doctrine_dbal.yaml:

The same flag is also exposed on DbalBundleConfig::$sqlCommentEnabled for programmatic control in tests or custom wiring.

PSR-3 Logger integration for bulk operations (opt-in)

AbstractDbalWriteExecutor and its descendants (BulkInserter, BulkUpdater, BulkUpserter, BulkDeleter) accept an optional Psr\Log\LoggerInterface. When no logger is injected, the executor uses a NullLogger and behaves exactly as before. When a logger is injected (e.g. Symfony\Monolog\Logger), each bulk operation emits four event types:

Event Level Payload
dbal.bulk.{op}.start INFO operation, table, chunk_size, total_rows
dbal.bulk.{op}.end INFO operation, table, rows_affected, duration_ms, peak_memory_mb
dbal.bulk.constraint_violation WARNING original DBAL message, attempt count
dbal.bulk.connection_error ERROR original DBAL message, attempt count

{op} is one of insert, update, upsert, delete, soft_delete.

Wire a logger via services.yaml:

composer.json already declares psr/log: ^3.0; no additional dependency is required.

Concurrency helpers (advisory locks and row-level locks)

TransactionService exposes four high-throughput concurrency helpers.

PostgreSQL advisory locks are application-level mutexes not tied to any table — useful for leader election or single-writer sections across an entire app.

tryAdvisoryLock($key) is the non-blocking variant; it returns false if another holder owns the lock. All three advisory-lock methods are PostgreSQL-only and throw LogicException on MySQL/MariaDB.

Row-level locks (SELECT ... WHERE ... FOR UPDATE) lock specific rows before a read-modify-write sequence so other transactions cannot modify them until the current transaction commits or rolls back.

The LockMode enum (FOR_UPDATE, FOR_NO_KEY_UPDATE, FOR_SHARE, FOR_KEY_SHARE) covers both PostgreSQL row-lock forms and MySQL 8+ semantics. On MySQL legacy, FOR_SHARE maps to LOCK IN SHARE MODE. FOR_NO_KEY_UPDATE and FOR_KEY_SHARE are PostgreSQL-only and throw LogicException on MySQL/MariaDB.

BulkTest Console Commands Setup

To use the test console commands related to bulk DBAL operations (insertMany, updateMany, upsertMany, deleteMany, softDeleteMany), add the following configuration to your services.yaml:


Test Table

To run the commands, you can use a pre-prepared table from an SQL file:

Manually run this SQL file in your test database before executing the commands.


Использование команд

Each command supports:

Example:


Logging Results

If the --track flag is provided, the command will save performance logs to a CSV file:

Each line in the log contains:

Compatibility

Known compatibility gaps

Registered Doctrine Types

The bundle registers seven Doctrine Types on build() so consumers can declare columns via #[Column(type: '...')] without hand-rolling Type registration:


All versions of dbal-bundle with dependencies

PHP Build Version
Package Version
Requires php Version ~8.3
ext-json Version *
ext-pdo Version *
doctrine/dbal Version ^4.2
doctrine/doctrine-bundle Version ^2.14
psr/log Version ^3.0
symfony/config Version ^7.2
symfony/dependency-injection Version ^7.2
symfony/http-kernel Version ^7.2
symfony/serializer Version ^7.2
symfony/uid Version ^7.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package elriseio/dbal-bundle contains the following files

Loading the files please wait ...