sunuazizrahayu / phpdotenv-for-codeigniter

Integrating phpdotenv ( .env ) files in CodeIgniter 3
MIT License
7 stars 3 forks source link

For Codeigniter 3, dotenv loading must be done in index.php #1

Open xalfeiran opened 9 months ago

xalfeiran commented 9 months ago

To properly load the .env variables into the configuration, dotenv must be loaded before Codeigniter.php


require APPPATH . 'vendor/autoload.php';
$dotenv = Dotenv\Dotenv::create(APPPATH);
$dotenv->load();
/*
 * --------------------------------------------------------------------
 * LOAD THE BOOTSTRAP FILE
 * --------------------------------------------------------------------
 *
 * And away we go...
 */
require_once BASEPATH.'core/CodeIgniter.php';
sunuazizrahayu commented 9 months ago

To properly load the .env variables into the configuration, dotenv must be loaded before Codeigniter.php

require APPPATH . 'vendor/autoload.php';
$dotenv = Dotenv\Dotenv::create(APPPATH);
$dotenv->load();
/*
 * --------------------------------------------------------------------
 * LOAD THE BOOTSTRAP FILE
 * --------------------------------------------------------------------
 *
 * And away we go...
 */
require_once BASEPATH.'core/CodeIgniter.php';

yes, you're right