This package is abandoned and no longer maintained. No replacement package was suggested.

DSN (Data Source Name) Parser

Maintainers

Details

github.com/andreyors/dsn

Source

Issues

Installs: 1 730

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 3

Forks: 1

Open Issues: 0

pkg:composer/andreyors/dsn

0.2.2 2023-08-11 09:33 UTC

This package is not auto-updated.

Last update: 2024-03-03 02:28:35 UTC


README

Latest Stable Version Build Status Downloads codecov Deps License M score PHP 7 ready

A DSN Parser for 12 factor apps

Getting started

Prerequisites

  • Composer

Supported

  • MySQL DSN
  • PostgreSQL DSN
  • Redis DSN
  • FTP and SFTP DSN

Installing

composer require andreyors/dsn

Usage

<?php

if (!isset($_ENV['APP_ENV'])) { // Production must have env vars provided via /etc/environment
    (new Symfony\Component\Dotenv\Dotenv())
        ->load(__DIR__ . '/.env');
}

$dsn = \AndreyOrs\Dsn::parse($_ENV['SYNCAPP_URL']);

return [
    'migration_dirs' => [
        'migrations' => __DIR__.'/config/db/migrations',
    ],
    'environments' => [
        'local' => [
            'adapter' => $dsn['adapter'] ?: '',
            'host' => $dsn['host'] ?: '',
            'username' => $dsn['user'] ?: '',
            'password' => $dsn['pass'] ?: '',
            'db_name' => $dsn['name'] ?: '',
            'charset' => 'utf8mb4',
        ],
    ],
];

Tests

composer test

License

This library is released under the MIT license.

More resources