andreyors / dsn
DSN (Data Source Name) Parser
Installs: 1 727
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: ^5.6.0 || ^7.0 || ^8.0
- ext-pcre: *
Requires (Dev)
- phpunit/phpunit: ^5.7 || ^7.0
This package is not auto-updated.
Last update: 2024-03-03 02:28:35 UTC
README
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.