2017 © Pedro Peláez
 

library silex-spot2-provider

Provider for the Spot2 orm (vlucas/spot2)

image

ronanchilvers/silex-spot2-provider

Provider for the Spot2 orm (vlucas/spot2)

  • Wednesday, May 3, 2017
  • by ronanchilvers
  • Repository
  • 1 Watchers
  • 0 Stars
  • 181 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 1 % Grown

The README.md

Silex Provider for the Spot2 ORM

SensioLabsInsight, (*1)

Spot2 is a simple ORM for Silex projects based on the data mapper pattern. You can read more about it on the github page or the documentation site., (*2)

This project comprises a service provider and utility for hooking Spot2 up to your Silex app., (*3)

Installation

The easiest mechanism is via composer. :, (*4)

composer require ronanchilvers/silex-spot2-provider ^1.0

Silex2 is supported in the master branch although there isn't yet a release. If you want to use the Silex2 version you can do:, (*5)

composer require ronanchilvers/silex-spot2-provider dev-master

Usage

To register the service provider you can do something like this:, (*6)

$app->register(new \Ronanchilvers\Silex\Provider\Spot2ServiceProvider(), [
    'spot2.connections' => [
        'default' => 'sqlite://path/to/my_database.sqlite'
    ]
]);

$app->get('/things', function() use ($app) {
    $mapper = $app['spot2.locator']->mapper('Entity\Thing');

    $this->render('things.twig', [
        'things' => $mapper->all()
    ]);
});

Utility trait

If you want to use the utility trait, just include it in your subclassed application., (*7)

class Application extends Silex\Application
{
    use \Ronanchilvers\Silex\Application\Spot2Trait;
}

You then get the following convenience methods., (*8)

mapper()

This method is a shortcut for getting a mapper out for a particular entity., (*9)

$app->get('/things', function() use ($app) {
    $mapper = $this->mapper('Entity\Thing');

    return $this->render('things.twig', [
        'things' => $mapper->all()
    ]);
});

spot2()

This method is a shortcut for getting the spot2 locator object. Most of the time you won't use this method (you'll probably use mapper() instead). It exists just to allow easy access to the locator if required., (*10)

$app->get('/things', function() use ($app) {
    $mapper = $this->spot2()->mapper('Entity\Thing');

    return $this->render('things.twig', [
        'things' => $mapper->all()
    ]);
});

Services Exposed

The Spot2ServiceProvider exposes the following services., (*11)

  • spot2.connections - an array of connection DSNs or DBAL style configuration arrays
  • spot2.connections.default - the name of the default connection to use. Spot2 will take the first defined one as the default if you don't set one explicitly.
  • spot2.config- the Spot2 config object
  • spot2.locator - the Spot2 locator object

The Versions

03/05 2017

dev-master

9999999-dev

Provider for the Spot2 orm (vlucas/spot2)

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ronan Chilvers

orm silex service provider spot2

12/01 2016

1.0

1.0.0.0

Provider for the Spot2 orm (vlucas/spot2)

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ronan Chilvers

orm silex service provider spot2

12/01 2016

1.0.x-dev

1.0.9999999.9999999-dev

Provider for the Spot2 orm (vlucas/spot2)

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ronan Chilvers

orm silex service provider spot2

12/01 2016

0.3

0.3.0.0

Provider for the Spot2 orm (vlucas/spot2)

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ronan Chilvers

orm silex service provider spot2

12/01 2016

0.2

0.2.0.0

Provider for the Spot2 orm (vlucas/spot2)

  Sources   Download

The Requires

 

The Development Requires

by Ronan Chilvers

12/01 2016

0.1

0.1.0.0

Provider for the Spot2 orm (vlucas/spot2)

  Sources   Download

The Requires

 

The Development Requires

by Ronan Chilvers