PHPackages                             cekurte/doctrinebundle - 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. cekurte/doctrinebundle

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

cekurte/doctrinebundle
======================

A extension of features of the doctrine library

v1.0.1(10y ago)17011MITPHPPHP &gt;=5.4

Since May 5Pushed 10y agoCompare

[ Source](https://github.com/jpcercal/doctrine-bundle)[ Packagist](https://packagist.org/packages/cekurte/doctrinebundle)[ Docs](https://github.com/jpcercal/cekurtedoctrinebundle)[ RSS](/packages/cekurte-doctrinebundle/feed)WikiDiscussions master Synced 1mo ago

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

Cekurte\\DoctrineBundle
=======================

[](#cekurtedoctrinebundle)

[![Build Status](https://camo.githubusercontent.com/0aba43313ce6f5ad4c2589f34e2fa710a4bfbf41df3fdf793a6acf5d28ce18d5/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6a7063657263616c2f646f637472696e652d62756e646c652f6d61737465722e7376673f7374796c653d737175617265)](http://travis-ci.org/jpcercal/doctrine-bundle)[![Code Climate](https://camo.githubusercontent.com/39fb1ea00ce5c0d71173be747beb57037e99be608b05a062af4f85bf7783839d/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6a7063657263616c2f646f637472696e652d62756e646c652f6261646765732f6770612e737667)](https://codeclimate.com/github/jpcercal/doctrine-bundle)[![Coverage Status](https://camo.githubusercontent.com/fa06d215c4047c8041b6a996449d1a8e8c46365d6334dc34938e66a3878836ab/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6a7063657263616c2f646f637472696e652d62756e646c652f62616467652e737667)](https://coveralls.io/r/jpcercal/doctrine-bundle)[![Latest Stable Version](https://camo.githubusercontent.com/ef3b4c5899af5d7745480d5867db2b144fbdf7e58e848e7371e6d354fc1a811c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63656b757274652f646f637472696e6562756e646c652e7376673f7374796c653d737175617265)](https://packagist.org/packages/cekurte/doctrinebundle)[![License](https://camo.githubusercontent.com/1f4b6b3caa863a8e524ef9b0c79af6937d7757fc559f3813b4ba600236b72699/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f63656b757274652f646f637472696e6562756e646c652e7376673f7374796c653d737175617265)](https://packagist.org/packages/cekurte/doctrinebundle)[![SensioLabsInsight](https://camo.githubusercontent.com/33e8b8e02e8ca2a3aa34e1bf7f4ecff160e901e906a756fde33d3c194533a075/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f36663336303636632d323064362d343938352d393863392d3833336636323832303665662f6d696e692e706e67)](https://insight.sensiolabs.com/projects/6f36066c-20d6-4985-98c9-833f628206ef)

- An extension to Doctrine DBAL that can be used to switch between database connections in runtime with Symfony 2, **contribute with this project**!

**If you liked of this library, give me a *star =)*.**

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

[](#installation)

- The package is available on [Packagist](http://packagist.org/packages/cekurte/doctrinebundle).
- The source files is [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) compatible.
- Autoloading is [PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md) compatible.

```
composer require cekurte/doctrinebundle
```

After, register the bundle in your AppKernel like this:

```
// app/AppKernel.php

// ...
public function registerBundles()
{
    $bundles = array(
        // ...
        new Cekurte\DoctrineBundle\CekurteDoctrineBundle(),
        // ...
    );

    // ...
    return $bundles;
}
```

Documentation
-------------

[](#documentation)

Well, firstly you must configure a doctrine database connection. So, add this in your config file.

```
# app/config/config.yml

# ...
doctrine:
    dbal:
        default_connection: dynamic
        connections:
            dynamic:
                driver:   "%database_driver%"
                host:     "%database_host%"
                port:     "%database_port%"
                dbname:   "%database_name%"
                user:     "%database_user%"
                password: "%database_password%"
                charset:  UTF8
                wrapper_class: "Cekurte\DoctrineBundle\DBAL\ConnectionWrapper"
```

After that, when you need change the database connection you can retrieve a service id named `doctrine.dbal.dynamic_connection` and call the method `forceSwitch`, see the example below.

```
