Skip to content

Instantly share code, notes, and snippets.

@roopunk
Created January 26, 2016 13:53
Show Gist options
  • Select an option

  • Save roopunk/41dac3fff458e4ea06de to your computer and use it in GitHub Desktop.

Select an option

Save roopunk/41dac3fff458e4ea06de to your computer and use it in GitHub Desktop.
hooks.php for Codeigniter Hook for integrating phpdotenv extension by vlucas Raw
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
| -------------------------------------------------------------------------
| Hooks
| -------------------------------------------------------------------------
| This file lets you define "hooks" to extend CI without hacking the core
| files. Please see the user guide for info:
|
| http://codeigniter.com/user_guide/general/hooks.html
|
*/
$hook['pre_system'] = function() {
$dotenv = new Dotenv\Dotenv(APPPATH);
$dotenv->load();
};
/* End of file hooks.php */
/* Location: ./application/config/hooks.php */
@roopunk
Copy link
Author

roopunk commented Jan 26, 2016

All the gists in this series :
https://gist.github.com/roopunk/756b3bd1935cac710686
https://gist.github.com/roopunk/18b6bdde6d52bded4f46
https://gist.github.com/roopunk/41dac3fff458e4ea06de

To enable phpdotenv in Codeigniter :

  1. Enable composer by setting $config['composer_autoload'] = true; in application/config/config.php
  2. Add the above composer.json file inside applications. Run "composer install"
  3. Enable hooks by setting $config['enable_hooks'] = TRUE; in application/config/config.php and add the above code in application/config/hooks.php

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment