mheap / silex-predis
Predis extension for Silex
Installs: 1 000
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.0
- predis/predis: ^1.1
Requires (Dev)
- phpunit/phpunit: ^6.4
- silex/silex: ^2.2
- squizlabs/php_codesniffer: ^3.1
This package is auto-updated.
Last update: 2020-11-26 18:46:37 UTC
README
Requirements
This extension only works with PHP 7.0+ and Silex 2. Version 1.0.0 is compatible with Silex 1.
Installation
Install with composer:
composer require mheap/silex-predis
Usage
Before you can use this extension you need to register it with your application. You specify a server to connect to at this point, as well as any other configuration options
$app->register(new SilexPredis\PredisExtension(), array( 'predis.server' => array( 'host' => '127.0.0.1', 'port' => 6379 ), 'predis.config' => array( 'prefix' => 'predis__' ) ));
Once the extension is registered, it'll be available as $app['predis']
:
$app->get('/', function() use($app) { $app['predis']->set('my_value', 'This is an example'); $value = $app['predis']->get('my_value'); });
Running the tests
You'll need Redis running on port 6379
locally to run the tests. If you don't have
Redis installed you can run docker-compose up
to run it in a container instead.