Git Product home page Git Product logo

yii-configbuilder's Introduction

yii-configbuilder

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.

yii-configbuilder's People

Contributors

crisu83 avatar

Watchers

Stratos Gerakakis avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.