magium/mcm-zend-db-factory 问题修复 & 功能扩展

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

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

magium/mcm-zend-db-factory

Composer 安装命令:

composer require magium/mcm-zend-db-factory

包简介

A factory for configuring zendframework/zend-db adapters using the Magium Configuration Manager

README 文档

README

This is a simple library that allows to configure a Zend DB adapter using the Magium Configuration Manager.

Setup

Using it is really easy.

First install via composer

composer require magium/zend-db-factory

Then wire your application to use MCM.

$factory = new \Magium\Configuration\MagiumConfigurationFactory();
$config = $factory->getManager()->getConfiguration(getenv('ENVIRONMENT'));

$redis = \Magium\ZendDbFactory\ZendDbFactory::factory($config);

You can also wire you Zend DI component to work with it:

$config = [
    'definition'  => [
        'class' => [
            \Zend\Db\Adapter\Adapter::class => [
                'instantiator' => [
                    \Magium\ZendDbFactory\ZendDbFactory::class,
                    'factory'
                ]
            ],
            Magium\ZendDbFactory\ZendDbFactory::class => [
                'methods'   => [
                    'factory'   => [
                        'config'    => [
                            'type'      => \Magium\Configuration\Config\ConfigurationRepository::class,
                            'required'  => true
                        ]
                    ]
                ]
            ]
        ]
    ]
];
$factory = new \Magium\Configuration\MagiumConfigurationFactory();
$di = new \Zend\Di\Di();
$configuration = new \Zend\Di\Config($config);
$configuration->configure($di);
$di->instanceManager()->addSharedInstance(
    $factory->getManager()->getConfiguration(),
    \Magium\Configuration\Config\ConfigurationRepository::class
);

$adapter = $di->get(\Zend\Db\Adapter\Adapter::class);

To Change Settings

Use the MCM configuration manager to change settings. For example, if you are going to use the CLI to make changes you have the following options:

[kschroeder@dev ~]$ vendor/configuration-manager magium:configuration:list-keys
Valid configuration keys
database/zenddb/driver

database/zenddb/hostname
        (A string containing a hostname or IP address of the database server. If the database is running on the same host as the PHP application, you may use 'localhost' or '127.0.0.1'.)

database/zenddb/username
        (Account identifier for authenticating a connection to the RDBMS server.)

database/zenddb/password
        (Account password credential for authenticating a connection to the RDBMS server.)

database/zenddb/dbname
        (Database instance name on the RDBMS server.)

database/zenddb/port
        (Some RDBMS servers can accept network connections on a administrator-specified port number.  The port parameter allow you to specify the port to which your PHP application connects, to match the port configured on the RDBMS server.)

database/adapter/charset
        (Specify the charset used for the connection.)

If you need to change the configuration to something else:

[kschroeder@dev ~]$ vendor/bin/magium-configuration magium:configuration:set database/zenddb/hostname hostname

Voila! You're done. No deployment necessary.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2017-05-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固