Git Product home page Git Product logo

phpdotenv-for-codeigniter's Introduction

PHP dotenv for codeigniter

Autodetect environment type and load variables from .env to getenv() automagically.

This is a PHP version of the original Ruby dotenv.

Manual Installation without Composer

  1. Copy folder system to your codeigniter projects.
  2. Add this code to your codeigniter index.php before codeigniter core loaded (before this text "* LOAD THE BOOTSTRAP FILE") :
    	/*
    	 * --------------------------------------------------------------------
    	 * LOAD PHP DOT ENV FILE
    	 * --------------------------------------------------------------------
    	 *
    	 * And away we go...
    	 *
    	 */
    	require_once BASEPATH . 'dotenv/autoloader.php';
    	
    	$dotenv = new Dotenv\Dotenv(__DIR__);
    	$dotenv->load();

Configuration

  1. Create .env according your environment by copy file .env.example for database configuration and the other configuration. Example : .env.development, .env.testing, .env.production

  2. Load configuration, in file application/config/database.php change to this configuration

	$db['default']['hostname'] = getenv('DB_HOST');
	$db['default']['username'] = getenv('DB_USERNAME');
	$db['default']['password'] = getenv('DB_PASSWORD');
	$db['default']['database'] = getenv('DB_DATABASE');
	$db['default']['dbdriver'] = getenv('DB_CONNECTION');
  1. Add ".env" to your .gitignore file
  2. It will be running, thank you

Release History

  • 0.1.1
    • CHANGE: Autodetect environment & Update Readme
  • 0.1.0
    • Initial version

Meta

Agung Jati Kusumo โ€“ @its_agungjk โ€“ [email protected]

Distributed under the MIT license. See LICENSE for more information.

https://github.com/agungjk/phpdotenv-for-codeigniter

Contributing

  1. Fork it (https://github.com/agungjk/phpdotenv-for-codeigniter/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

phpdotenv-for-codeigniter's People

Watchers

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.