Skip to content

williancarminato/respect-relational-silex-provider

Repository files navigation

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!

About

Respect Relational Service Provider to use with Silex microframework.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published