PHP code example of ronanchilvers / silex-spot2-provider

1. Go to this page and download the library: Download ronanchilvers/silex-spot2-provider library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ronanchilvers / silex-spot2-provider example snippets


$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()
    ]);
});

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

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

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

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

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