承接 crisu83/yii-configbuilder 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

crisu83/yii-configbuilder

Composer 安装命令:

composer require crisu83/yii-configbuilder

包简介

Helper for building application configurations for the Yii PHP framework.

关键字:

README 文档

README

Helper for building application configurations for the Yii PHP framework.

Basic configuration

Usage

To use the config builder you simply need to load it in your entry script:

<?php
$yii = __DIR__ . '/path/to/yii.php';
$builder = __DIR__ . '/path/to/ConfigBuilder.php';

require_once($yii);
require_once($builder);

$config = ConfigBuilder::build(array(
    __DIR__ . '/protected/config/common.php',
    __DIR__ . '/protected/config/web.php',
    __DIR__ . '/protected/config/dev.php',
    __DIR__ . '/protected/config/local.php',
));

Yii::createWebApplication($config)->run();

index.php

Environment specific configurations

If you need different environments in your application you can use the buildForEnv method together with the EnvCommand to easily set environment specific configurations.

Configuration

Add the env command to your console config file (usually protected/config/console.php):

// console application configuration
return array(
    .....
    'commandMap' => array(
        'env' => array(
            'class' => 'path.alias.to.EnvCommand',
            // optional configurations
            'runtimePath' => 'application.runtime', // the path to the application runtime folder
            'envPaths' => array('application.config.environments'), // the paths to application environment configs
        ),
    ),
);

console.php

Usage

Update your entry script (usually index.php) to use the buildForEnv method.

<?php
$config = ConfigBuilder::buildForEnv(array(
    __DIR__ . '/protected/config/common.php',
    __DIR__ . '/protected/config/web.php',
    __DIR__ . '/protected/config/environments/{environment}.php',
    __DIR__ . '/protected/config/local.php',
), __DIR__ . '/protected/runtime/environment');

index.php

Now you can use the env command to set the active environment (replace {environment} is the name of the environment):

yiic env {environment}

Note: You do not need to create the environment configuration files, the command will prompt you to create them if they do not exist.

统计信息

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

GitHub 信息

  • Stars: 12
  • Watchers: 2
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2013-02-19