I'm trying to include .env file in Codeigniter 3 by following steps:
integrating.env files in CodeIgniter 3.0 using hooks
But, it returns the following error
A PHP Error was encountered Severity: 4096
Message: Argument 1 passed to Dotenv\Dotenv::__construct() must be an instance of Dotenv\Loader, string given, called in /application/config/hooks.php on line 5 and defined
Filename: src/Dotenv.php
Line Number: 31
My /application/config/hooks.php file is configured in the same way as indicated in the tutorial:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
$hook['pre_system'] = function() {
$dotenv = new Dotenv\Dotenv(APPPATH);
$dotenv->load();
};
I had done a quick research and unable to find a perfect solution for the problem occurred, Can you guys please help me to find out a solution?