2017 © Pedro PelĆ”ez
 

symfony-bundle doctrinebundle

A extension of features of the doctrine library

image

cekurte/doctrinebundle

A extension of features of the doctrine library

  • Tuesday, May 3, 2016
  • by jpcercal
  • Repository
  • 1 Watchers
  • 1 Stars
  • 635 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Cekurte\DoctrineBundle

Build Status Code Climate Coverage Status Latest Stable Version License SensioLabsInsight, (*1)

  • 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 =)., (*2)

Installation

  • The package is available on Packagist.
  • The source files is PSR-2 compatible.
  • Autoloading is PSR-4 compatible.
composer require cekurte/doctrinebundle

After, register the bundle in your AppKernel like this:, (*3)

// app/AppKernel.php

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

    // ...
    return $bundles;
}

Documentation

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

# 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., (*5)

<?php

namespace YourNamespace\YourBundleBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;

class YourController extends Controller
{
    public function indexAction()
    {
        // ...

        // Change the current database connection...
        $this
            ->get('doctrine.dbal.dynamic_connection')
            ->forceSwitch(
                $dbHost,
                $dbName,
                $dbUser,
                $dbPassword,
                $dbOptions
            )
        ;
    }
}

Contributing

  1. Give me a star =)
  2. Fork it
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Make your changes
  5. Run the tests, adding new ones for your own code if necessary (vendor/bin/phpunit)
  6. Commit your changes (git commit -am 'Added some feature')
  7. Push to the branch (git push origin my-new-feature)
  8. Create new Pull Request

The Versions

03/05 2016

dev-master

9999999-dev https://github.com/jpcercal/cekurtedoctrinebundle

A extension of features of the doctrine library

  Sources   Download

MIT

The Requires

 

The Development Requires

doctrine multitenancy querystring

03/05 2016

v1.0.1

1.0.1.0 https://github.com/jpcercal/cekurtedoctrinebundle

A extension of features of the doctrine library

  Sources   Download

MIT

The Requires

 

The Development Requires

doctrine multitenancy querystring

03/05 2016

dev-develop

dev-develop https://github.com/jpcercal/cekurtedoctrinebundle

A extension of features of the doctrine library

  Sources   Download

MIT

The Requires

 

The Development Requires

doctrine multitenancy querystring

05/05 2015

v1.0.0

1.0.0.0 https://github.com/jpcercal/cekurtedoctrinebundle

A extension of features of the doctrine library

  Sources   Download

MIT

The Requires

 

The Development Requires

doctrine multitenancy querystring