Respect Relational Service Provider to use with Silex microframework.
Permalink
Failed to load latest commit information.
src/Carminato/Silex/Provider/Respect Including provider Sep 19, 2013
tests/Carminato/Silex/Provider/Respect Including provider Sep 19, 2013
.gitignore Including provider Sep 19, 2013
.travis.yml Including travis file Sep 19, 2013
LICENSE Initial commit Sep 19, 2013
README.md
composer.json Including provider Sep 19, 2013
composer.lock Including provider Sep 19, 2013
phpunit.xml.dist Including provider Sep 19, 2013

README.md

Respect Relational Service Provider Build Status

Provides Respect Relational Mapper to use as services on Silex applications.

Features

  • Awesome Relational database persistence tool, see Respect/Relational
  • Multiple databases connections

Requirements

  • PHP 5.3+
  • Respect/Relational

Instalation

Package available on Composer. Autoloading with composer is PSR-0 compatible.

Usage

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']

Enjoy!