Provides Respect Relational Mapper to use as services on Silex applications.
- Awesome Relational database persistence tool, see Respect/Relational
- Multiple databases connections
- PHP 5.3+
- Respect/Relational
Package available on Composer. Autoloading with composer is PSR-0 compatible.
To use the provider, register RespectRelationalServiceProvider
and specify at least one connection.
<?php
use Silex\Application;
use Carminato\Silex\Provider\Respect\RespectRelationalServiceProvider;
$app = new Application;
$app->register(new RespectRelationalServiceProvider(), array(
'respect.pdo.instances' => array(new \PDO('sqlite::memory:'))
)
);
The default Mapper will now be accessible with respect.mapper
in the app container.
<?php
$mapper = $app['respect.mapper'];
You can pass as many respect.pdo.instances
as you want.
<?php
use Silex\Application;
use Carminato\Silex\Provider\Respect\RespectRelationalServiceProvider;
$app = new Application;
$app->register(new RespectRelationalServiceProvider(), array(
'respect.pdo.instances' => array(
'mymapper1' => new \PDO('sqlite::memory:'),
'mymapper2' => new \PDO('sqlite::memory:')
)
)
);
And then access each one with his respective array key using the respect.mappers
.
<?php
$mapper1 = $app['respect.mappers']['mymapper1']
$mapper2 = $app['respect.mappers']['mymapper2']