PHPackages                             bravesheep/database-url-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. bravesheep/database-url-bundle

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

bravesheep/database-url-bundle
==============================

Determine Symfony2 database settings from a single URL-based parameter

v0.2.0(6y ago)238.8k↓23.3%4[1 issues](https://github.com/bravesheep/database-url-bundle/issues)1MITPHP

Since May 21Pushed 6y ago3 watchersCompare

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

READMEChangelog (1)Dependencies (4)Versions (6)Used By (1)

BravesheepDatabaseUrlBundle
===========================

[](#bravesheepdatabaseurlbundle)

A Symfony2 bundle for parsing the contents of a url that specifies which database to use.

Installation and configuration
------------------------------

[](#installation-and-configuration)

Using [Composer](https://getcomposer.org/) add the bundle to your dependencies using the require command: `composer require bravesheep/database-url-bundle:dev-master`.

### Add the bundle to your AppKernel

[](#add-the-bundle-to-your-appkernel)

Add the bundle in your `app/AppKernel.php`. **Note**: in order for the parameters defined by this bundle to be picked up by Doctrine, you need to include this bundle before including the `Doctrine\Bundle\DoctrineBundle\DoctrineBundle`bundle.

```
public function registerBundles()
{
    return array(
        // ...
        new Bravesheep\DatabaseUrlBundle\BravesheepDatabaseUrlBundle(),
        // ...
    );
}
```

### Configure which urls should be rewritten to parameters

[](#configure-which-urls-should-be-rewritten-to-parameters)

For this bundle to work you need to specify which urls need to be rewritten to basic parameters. This bundle can handle any number of urls by configuring the correct properties under `bravesheep_database_url.urls`. Take a look at this example configuration:

```
bravesheep_database_url:
    urls:
        default:
            url: %database_url%
            prefix: database_
```

In this case we take the value of the `database_url` parameter and create parameters from it prefixed with `database_`.

Usage
-----

[](#usage)

Take a look at this `parameters.yml.dist` which is distributed by the Symfony2 Standard Edition:

```
parameters:
    database_driver: pdo_mysql
    database_host: 127.0.0.1
    database_port: ~
    database_name: symfony
    database_user: root
    database_password: ~

    mailer_transport: smtp
    mailer_host: 127.0.0.1
    mailer_user: ~
    mailer_password: ~

    locale: en
    secret: ThisTokenIsNotSoSecretChangeIt

    debug_toolbar: true
    debug_redirects: false
    use_assetic_controller: true
```

As you can see there is a grand total of 6 parameters required for just specifying the database connection. If we could instead use a URL for specifying the database this might be reduced to just this:

```
parameters:
    database_url: mysql://root@127.0.0.1/symfony

    mailer_transport: smtp
    mailer_host: 127.0.0.1
    mailer_user: ~
    mailer_password: ~

    locale: en
    secret: ThisTokenIsNotSoSecretChangeIt

    debug_toolbar: true
    debug_redirects: false
    use_assetic_controller: true
```

This is exactly what the BravesheepDatabaseUrlBundle is supposed to do. The example configuration in the previous section reads this `database_url` parameter and creates the individual `database_driver`, `database_host`, `database_port`, `database_name`, `database_user` and `database_password`.

In general this bundle takes any database url and creates the following parameters, prefixed with the prefix you specify: `driver`, `host`, `port`, `name`, `user`, `password`, `path` and `memory`. The `path` and `memory` variables are used to indicate the SQLite path and a boolean indicating whether to use an in-memory SQLite database respectively.

### Accepted urls

[](#accepted-urls)

URLs are generally formatted in `scheme://user:password@host:port/database` format. The following schemes are understood:

- `postgres`, `postgresql`, `pgsql` and `pdo_pgsql` for the `pdo_pgsql` (PostgreSQL) driver
- `mysql` and `pdo_mysql` for the `pdo_mysql` (MySQL) driver
- `sqlite` and `pdo_sqlite` for the `pdo_sqlite` (SQLite) driver
- `mssql` and `pdo_mssql` for the `pdo_mssql` (MSSQL) driver

Username and password can be omitted if they are not required, as well as the port in case it is the default. For SQLite the format to use is:

- `sqlite:///path/to/sqlite/db` for an absolute path to a SQLite database.
- `sqlite:///%kernel.root_dir%/to/db.sql?relative` for a relative path using the kernel.root\_dir as the base
- `sqlite://:memory:` for an in-memory database

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70% 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 ~472 days

Total

5

Last Release

2489d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/86a9633404b0317dcde9ecb9c54f88c4d54bc42bb137d462933773bbe3a539b9?d=identicon)[rnijveld](/maintainers/rnijveld)

![](https://www.gravatar.com/avatar/664f27a4241e63b3e2cff68a436e2ef6930c926dd0ae0fb4973bfb969cab1754?d=identicon)[marlon](/maintainers/marlon)

---

Top Contributors

[![rnijveld](https://avatars.githubusercontent.com/u/193783?v=4)](https://github.com/rnijveld "rnijveld (7 commits)")[![hdoordt](https://avatars.githubusercontent.com/u/17907879?v=4)](https://github.com/hdoordt "hdoordt (1 commits)")[![Majkl578](https://avatars.githubusercontent.com/u/144181?v=4)](https://github.com/Majkl578 "Majkl578 (1 commits)")[![vacuum-car](https://avatars.githubusercontent.com/u/32087870?v=4)](https://github.com/vacuum-car "vacuum-car (1 commits)")

### Embed Badge

![Health badge](/badges/bravesheep-database-url-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/bravesheep-database-url-bundle/health.svg)](https://phpackages.com/packages/bravesheep-database-url-bundle)
```

###  Alternatives

[a2lix/translation-form-bundle

Translate your doctrine objects easily with some helpers

3376.9M38](/packages/a2lix-translation-form-bundle)[sonata-project/entity-audit-bundle

Audit for Doctrine Entities

644989.8k1](/packages/sonata-project-entity-audit-bundle)[kreait/firebase-bundle

Symfony Bundle for the Firebase Admin SDK

1534.7M2](/packages/kreait-firebase-bundle)

PHPackages © 2026

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