Giter Club home page Giter Club logo

yii2-dev-env's Introduction

yii2-dev-env

An easy mod for Yii2 basic application to switch between development and production environments when using Composer to install the project.

Add this extension to the require-dev section of your project's composer.json file.

Edit the project's index.php file as follows:

Remove these lines

    // comment out the following two lines when deployed to production
    defined('YII_DEBUG') or define('YII_DEBUG', true);
    defined('YII_ENV') or define('YII_ENV', 'dev');

Add these lines in their place

    // If the package is installed via composer with --no-dev then yii2-dev-env will not be included
    // If the development packages are included then including dev-env.php will set the YII_DEBUG and
    // YII_ENV constants to their development/debug values, otherwise they default to production values
    $dev_env = __DIR__ . '/../vendor/garya/yii2-dev-env/dev-env.php';
    if(file_exists($dev_env))
    {
        include $dev_env;
    }

Now, when you use Composer to install the project with the --no-dev option the dev-env.php file will not be installed and the environment will be set as production. When the development dependencies are included the environment will be set to development with debug enabled.

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.