douliangpo0128 2019-02-11 11:43
浏览 161
已采纳

Codeigniter - 包含env文件时出现问题

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?

  • 写回答

3条回答 默认 最新

  • douyingbei1458 2019-02-15 12:47
    关注

    I was able to install phpdotenv in a different way from the instructions in the first tutorial.
    In this tutorial installation is done without the use of Composer:

    PHPDotenv for CodeIgniter (Installation without Composer)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程