ngabor84/laravel-dbconnstring-parser 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ngabor84/laravel-dbconnstring-parser

最新稳定版本:2.0.0

Composer 安装命令:

composer require ngabor84/laravel-dbconnstring-parser

包简介

Small service to parse database connection string into parts

README 文档

README

GitHub license

Database Connection String Parser

Small service to parse database connection string into parts.

About

This package allows you to parse database connection string into parts.

Installation

Require the ngabor84/laravel-dbconnstring-parser package in your composer.json and update your dependencies:

composer require ngabor84/laravel-dbconnstring-parser

Usage with Laravel

Add the service provider to the providers array in the config/app.php config file as follows:

'providers' => [
    ...
    \Service\Database\ConnectionStringParser\Providers\ServiceProvider::class,
]

In your database config file you can use it like this:

$connection = ConnectionStringParser::parse(env('DATABASE_URL'));

return [
    'default' => 'pgsql',
    'connections' => [
        'pgsql' => [
            'driver' => 'pgsql',
            'host' => $connection->getHost(),
            'username' => $connection->getUserName(),
            'password' => $connection->getPassword(),
            'port' => $connection->getPort(),
            'database' => $connection->getDatabase(),
            'charset' => 'utf8',
            'options' => array(
                PDO::ATTR_PERSISTENT => true
            )
        ]
    ]
];

Usage with Lumen

Add the following snippet to the bootstrap/app.php file under the providers section as follows:

// uncomment this line to enable Facades
$app->withFacades();
...
$app->register(\Service\Database\ConnectionStringParser\Providers\ServiceProvider::class);

In your database config file you can use it like this:

$connection = ConnectionStringParser::parse(env('DATABASE_URL'));

return [
    'default' => 'pgsql',
    'connections' => [
        'pgsql' => [
            'driver' => 'pgsql',
            'host' => $connection->getHost(),
            'username' => $connection->getUserName(),
            'password' => $connection->getPassword(),
            'port' => $connection->getPort(),
            'database' => $connection->getDatabase(),
            'charset' => 'utf8',
            'options' => array(
                PDO::ATTR_PERSISTENT => true
            )
        ]
    ]
];

统计信息

  • 总下载量: 3.15k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-10-26