icecave/lace

A DSN parser for Doctrine databases and cache drivers.

Installs: 270

Dependents: 1

Stars: 3

Watchers: 2

Open Issues: 1

Language: PHP

0.1.0 2014-08-26 09:24 UTC

README

Build Status Test Coverage SemVer

Lace is a DSN parser for Doctrine database and cache connections.

Lace was initially created to parse DSN URIs stored in environment variables on the Heroku platform.

Examples

Database DSN

The DatabaseDsnParser class is responsible for parsing database DSNs into arrays compatible with Doctrine DBAL's driver manager.

The following drivers are currently supported:

  • PostgreSQL
  • MySQL
  • SQLite
use Icecave\Lace\DatabaseDsnParser;

$parser = new DatabaseDsnParser;
$options = $parser->parse('postgres://username:password@hostname:1234/database');

print_r($options);
Array
(
    [driver] => pdo_pgsql
    [user] => username
    [password] => password
    [host] => hostname
    [port] => 1234
    [dbname] => database
)

Cache DSN

The CacheDsnParser class is responsible for parsing DSNs into arrays with the necessary information.

The following drivers are currently supported:

  • Redis
use Icecave\Lace\CacheDsnParser;

$parser = new CacheDsnParser;
$options = $parser->parse('redis://username:password@hostname:1234');

print_r($options);
Array
(
    [host] => hostname
    [port] => 1234
    [password] => password
)

Contact us