val/doctrine-table-prefix-service-provider

Doctrine event listener to dynamically add a table prefix.

v1.0.0 2014-03-31 10:34 UTC

This package is not auto-updated.

Last update: 2024-03-16 13:05:13 UTC


README

Doctrine event listener to dynamically add a table prefix.

Features

  • Add a table prefix for any configured database directly in the configuration array.
  • Framework agnostic (since it extends Pimple).

The TablePrefix code is totally taken from the documentation.

Installation

composer require val/doctrine-table-prefix-service-provider

Usage

Assuming $app is an instance of Pimple, Silex\Application or Cilex\Application.

Configuration

Single DB

<?php

$app['db.options']['prefix'] = 'prefix_';

Multiple DBs

<?php

$app['dbs.options']['first']['prefix'] = 'first_';
$app['dbs.options']['second']['prefix'] = 'second_';

Registration

Pimple

<?php

use Val\Pimple\Provider\DoctrineTablePrefixServiceProvider;

new DoctrineTablePrefixServiceProvider()->register($app);

Silex

<?php

use Val\Silex\Provider\DoctrineTablePrefixServiceProvider;

$app->register(new DoctrineTablePrefixServiceProvider());

Cilex

<?php

use Val\Cilex\Provider\DoctrineTablePrefixServiceProvider;

$app->register(new DoctrineTablePrefixServiceProvider());