HandlerSocket Service Provider for Silex
silex 2.x
The best way to install HandlerSocketServiceProvider is to use a Composer:
composer require junker/handlersocket-service-provider
use HSAL\HSAL;
use Junker\Silex\Provider\HandlerSocketServiceProvider;
$app->register(new HandlerSocketServiceProvider(), [
'hs.options' => [
'host' => 'localhost',
'dbname' => 'testdb'
]
]);
# or
$app->register(new HandlerSocketServiceProvider(), [
'hs.options' => [
'driver' => HSAL::DRIVER_HSPHP,
'host' => 'localhost',
'dbname' => 'testdb',
'port_read' => 9998,
'port_write' => 9999,
'timeout' => 5
]
]);
$page = $app['hs'] = $hs->fetchAssoc('pages', ['id', 'title'], [HSAL::INDEX_PRIMARY => 5]);