PHPackages                             squirrelphp/queries-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. squirrelphp/queries-bundle

ActiveLibrary[Database &amp; ORM](/categories/database)

squirrelphp/queries-bundle
==========================

Symfony integration of squirrelphp/queries - automatic assembling of decorated connections.

v0.15.8(5mo ago)13.4k1MITPHPPHP &gt;=8.4CI failing

Since Apr 23Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/squirrelphp/queries-bundle)[ Packagist](https://packagist.org/packages/squirrelphp/queries-bundle)[ Docs](https://github.com/squirrelphp/queries-bundle)[ RSS](/packages/squirrelphp-queries-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (14)Versions (30)Used By (1)

Squirrel Queries Integration for Symfony
========================================

[](#squirrel-queries-integration-for-symfony)

[![Build Status](https://camo.githubusercontent.com/e7b88b04bdd36f0f365d715fe941c3f97beb087ffc45060246c60c3c7bdca44b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636f6d2f737175697272656c7068702f717565726965732d62756e646c652e737667)](https://travis-ci.com/squirrelphp/queries-bundle) [![PHPStan](https://camo.githubusercontent.com/2f409849f7a47b1ac5bed1d59b866f287a76ad211c6bf3a10263d769a3354579/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374796c652d6c6576656c2532306d61782d737563636573732e7376673f7374796c653d666c61742d726f756e64266c6162656c3d7068707374616e)](https://camo.githubusercontent.com/2f409849f7a47b1ac5bed1d59b866f287a76ad211c6bf3a10263d769a3354579/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7374796c652d6c6576656c2532306d61782d737563636573732e7376673f7374796c653d666c61742d726f756e64266c6162656c3d7068707374616e) [![Packagist Version](https://camo.githubusercontent.com/810e96d91defbf6e1981c93fb2fe480cb37964465ac66ee25e0d61f649fcd106/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f737175697272656c7068702f717565726965732d62756e646c652e7376673f7374796c653d666c61742d726f756e64)](https://packagist.org/packages/squirrelphp/queries-bundle) [![PHP Version](https://camo.githubusercontent.com/c0d1310a94bf8107bddae35dc6b03b1b2e320e548e23d4e886fc8596381820cd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f737175697272656c7068702f717565726965732d62756e646c652e737667)](https://packagist.org/packages/squirrelphp/queries-bundle) [![Software License](https://camo.githubusercontent.com/4f9c8f8c009336d7177cf697d694e2e763e5e707f1a6224ab0d295465eadffbd/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d737563636573732e7376673f7374796c653d666c61742d726f756e64)](LICENSE)

Integration of [squirrelphp/queries](https://github.com/squirrelphp/queries) into Symfony through service tags and bundle configuration.

Installation
------------

[](#installation)

```
composer require squirrelphp/queries-bundle

```

Configuration
-------------

[](#configuration)

Enable the bundle in your project by adding `Squirrel\QueriesBundle\SquirrelQueriesBundle` to the list of bundles (usually in `config/bundles.php`).

Create a configuration file for your connections, here is an example:

```
squirrel_queries:
    connections:
        default:
            type: 'mysql'
            host: '%env(DB_HOST)'
            port: '%env(DB_PORT)'
            user: '%env(DB_USER)'
            password: '%env(DB_PASSWORD)'
            dbname: '%env(DB_DBNAME)'
        error:
            type: 'mariadb'
            host: 'mariadb_database'
            port: 9999
            user: 'app'
            password: 'hg84kdhgjg84'
            dbname: 'app_prod'
            ssl:
                rootCertificatePath: '/home/app/ssl/ca.crt'
                privateKeyPath: '/home/app/ssl/ca.key'
                certificatePath: '/home/app/ssl/cert.crt'
                verification: 'CaAndHostname'
        sqlite:
            type: 'sqlite'
            path: '/home/database.db'

```

The example shows all possible values you can set (except for `charset`, which is explained further below but should ideally be omitted/left at the default). `type` can only be either `mysql`, `mariadb`, `pgsql` or `sqlite`. `mysql` and `mariadb` are functionally equivalent.

Type `sqlite` only supports the optional path parameter to the database file, when not provided (or null) it creates an in-memory database.

For `mysql`, `mariadb` and `pgsql` connections the following values can be provided:

- `host` can be a hostname or IP in order to connect to the database server
- `port` is an integer and is optional (defaults to 3306 for mysql/mariadb, 5432 for postgresql)
- `user` is the username with which to connect
- `password` is the password to connect with
- `dbname` is the default database to open and is optional, by default (or with a value of null) no database is opened
- `charset` can be provided and defaults to `utf8mb4` for mysql/mariadb and `UTF8` for postgresql, the recommendation is to leave it at the default
- `ssl` sets additional values so the connection will be encrypted (if omitted or set to null no encryption is used):
    - `rootCertificatePath` is the path to the root certificate file used by the database server
    - `privateKeyPath` is the path to the private key the client sends to the database server
    - `certificatePath` is the path to the certificate file the client sends to the database server
    - `verification` can be one of the following values:
        - `CaAndHostname` (which is the default) enforces that the CA of the database server certificate matches the CA in `rootCertificatePath` and that the hostname of the server certificate matches the hostname in `host`
        - `Ca` enforces that the CA of the database server certificate matches the CA in `rootCertificatePath` (the hostname is not verified) - beware that this does not work for mysql/mariadb and will throw an exception for those connections, because just checking the CA is not supported by PHP for mysql/mariadb (it works as expected for postgresql)
        - `None` will not check the CA or the hostname of the server certificate

The connection named `default` will be registered as `Squirrel\Queries\DBInterface` which you can then use as a type hint in your services. All connections also get registered as services that start with `squirrel.connection.`, so in the above example the following services would be defined: `squirrel.connection.default`, `squirrel.connection.error` and `squirrel.connection.sqlite`.

### Common behavior of all connections

[](#common-behavior-of-all-connections)

The following options are hardcoded into all connections and mostly differ from the common defaults in PHP database connections (see [squirrelphp/connection](https://github.com/squirrelphp/connection) for more details):

- Emulation of prepares is turned off, so real query and values separation is enabled instead of emulating it (which is usually the default in PHP). You should not notice this in any way, even in terms of performance: it was tested, and when script and database are running in the same network there is no measureable difference. Your script and database would need to be apart by some distance for any possible effect to manifest. On the other hand, the separation of queries and values has undeniable security benefits and is the way the underlying database client libraries are designed to work.
- For MySQL/MariaDB, the "affected rows" reported for UPDATE queries are the "found rows" in the database, even if nothing changed by executing the UPDATE. By default with MySQL/MariaDB in PHP you get the "changed rows", which is a behavior no other database has or even supports, so MySQL/MariaDB is configured to behave more like any other database. Getting the "found rows" count can be useful information, while relying on the "changed rows" count relies on special behavior in one database system.
- Executing multiple statements in one query is disabled. Multiple statements per query were a source of security exploits in the past, are often not easy to port between different database systems and have little real world relevance. Use transactions instead, which is a guaranteed way to execute multiple statements together, or use parallel connections / multiple connections if speed is an issue.

Adding layers
-------------

[](#adding-layers)

By default, this bundle creates DBInterface services with an implementation layer and an error handling layer (see [squirrelphp/queries](https://github.com/squirrelphp/queries) for details).

If you want to add additional layers to decorate DBInterface, create a service for each additional layer and tag it with `squirrel.layer`. Make sure the service implements `Squirrel\Queries\DBRawInterface` and to add the trait `Squirrel\Queries\DBPassToLowerLayerTrait` in the service. Define a `priority` for the tag and set it to below zero if you want to inject it between the implementation and the error handler, or above zero if it should be above the error handler.

Example for the service definition of a logger which logs deadlocks / connection timeouts before the error handler automatically retries the query/transaction:

```
services:
    Squirrel\QueriesBundle\Examples\SQLLogTemporaryFailuresListener:
        tags:
            - { name: squirrel.layer, priority: -250 }

```

Because the priority is below zero it is a layer beneath the error handler. You can find a possible implementation in the examples directory.

Symfony Profiler
----------------

[](#symfony-profiler)

When using Symfony Profiler this library offers similar integration like the DoctrineBundle automatically - so you can check what queries were sent to the database and how long they took.

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance70

Regular maintenance activity

Popularity20

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~86 days

Recently: every ~68 days

Total

29

Last Release

170d ago

PHP version history (6 changes)v0.5PHP ^7.2

v0.10PHP ^7.4

v0.11PHP &gt;=7.4

v0.13PHP &gt;=8.0

v0.15PHP &gt;=8.2

v0.15.8PHP &gt;=8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/8cd200dc74af2d77e8c480000a7e3bab0b8a98fae4b399d306b3d332354f8177?d=identicon)[iquito\_ch](/maintainers/iquito_ch)

---

Top Contributors

[![iquito](https://avatars.githubusercontent.com/u/973653?v=4)](https://github.com/iquito "iquito (33 commits)")

---

Tags

phpsymfonybundleabstractiondatabasemysqlsqlitepgsql

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/squirrelphp-queries-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/squirrelphp-queries-bundle/health.svg)](https://phpackages.com/packages/squirrelphp-queries-bundle)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[fresh/doctrine-enum-bundle

Provides support of ENUM type for Doctrine2 in Symfony applications.

4636.8M12](/packages/fresh-doctrine-enum-bundle)[kreait/firebase-bundle

Symfony Bundle for the Firebase Admin SDK

1534.7M2](/packages/kreait-firebase-bundle)[vcian/laravel-db-auditor

Database DB Auditor provide leverage to audit your MySql,sqlite, PostgreSQL database standards and also provide options to add constraints in table.

28535.1k1](/packages/vcian-laravel-db-auditor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
