2017 © Pedro Peláez
 

yii-extension yii-configbuilder

Helper for building application configurations for the Yii PHP framework.

image

crisu83/yii-configbuilder

Helper for building application configurations for the Yii PHP framework.

  • Wednesday, March 27, 2013
  • by crisu83
  • Repository
  • 3 Watchers
  • 14 Stars
  • 618 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 8 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

yii-configbuilder

Helper for building application configurations for the Yii PHP framework., (*1)

Basic configuration

Usage

To use the config builder you simply need to load it in your entry script:, (*2)

<?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, (*3)

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., (*4)

Configuration

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

// 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, (*6)

Usage

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

<?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, (*8)

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

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., (*10)

The Versions

27/03 2013

dev-master

9999999-dev

Helper for building application configurations for the Yii PHP framework.

  Sources   Download

BSD-3-Clause

configuration