Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/agungjk/phpdotenv-for-codeigniter
Loads environment variables from `.env` to `getenv()` automagically.
https://github.com/agungjk/phpdotenv-for-codeigniter
codeigniter environment htaccess-files nginx php
Last synced: 4 months ago
JSON representation
Loads environment variables from `.env` to `getenv()` automagically.
- Host: GitHub
- URL: https://github.com/agungjk/phpdotenv-for-codeigniter
- Owner: agungjk
- License: mit
- Created: 2015-10-19T07:31:50.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-05-08T05:01:18.000Z (over 6 years ago)
- Last Synced: 2024-09-30T00:40:57.061Z (4 months ago)
- Topics: codeigniter, environment, htaccess-files, nginx, php
- Language: PHP
- Size: 64.5 KB
- Stars: 103
- Watchers: 5
- Forks: 47
- Open Issues: 4
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](https://github.com/bkeepers/dotenv).
![](cover.png)
## 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") :
```php
/*
* --------------------------------------------------------------------
* 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
```php
$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');
```
3. Add ".env" to your .gitignore file
4. 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](https://twitter.com/its_agungjk) – [email protected]
Distributed under the MIT license. See ``LICENSE`` for more information.
[https://github.com/agungjk/phpdotenv-for-codeigniter](https://github.com/agungjk/phpdotenv-for-codeigniter)
## Contributing
1. Fork it ()
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