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 运筹学中在线排序的时间在线排序的在线LPT算法
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧