duanfei8399 2019-04-05 19:01
浏览 113
已采纳

安装Braintree并收到错误“Uncaught InvalidArgumentException:Dotenv:Environment file .env not found or not readable。”

I'm trying to get Braintree working on my local Ubuntu environment and I'm getting the error Uncaught InvalidArgumentException: Dotenv: Environment file .env not found or not readable. I think its relating to the backslash in the code below. I'm not sure how to fix it though, can anyone help with this?

This is the error I'm receiving:

[Fri Apr 05 14:14:26.170718 2019] [php7:error] [pid 88156] [client ::1:52042] PHP Fatal error:  Uncaught InvalidArgumentException: Dotenv: Environment file .env not found or not readable. Create file with your environment settings at /var/www/html/myskinpro/includes/../example.env/.env in /var/www/html/myskinpro/vendor/vlucas/phpdotenv/src/Loader.php:78
Stack trace:
#0 /var/www/html/myskinpro/vendor/vlucas/phpdotenv/src/Loader.php(51): Dotenv\\Loader->ensureFileIsReadable()
#1 /var/www/html/myskinpro/vendor/vlucas/phpdotenv/src/Dotenv.php(41): Dotenv\\Loader->load()
#2 /var/www/html/myskinpro/includes/braintree_init.php(7): Dotenv\\Dotenv->load()
#3 /var/www/html/myskinpro/payusd/index.php(1): require_once('/var/www/html/m...')
#4 {main}
  thrown in /var/www/html/myskinpro/vendor/vlucas/phpdotenv/src/Loader.php on line 78

This is the code that's causing the problem:

<?php
session_start();
require_once("../vendor/autoload.php");

if(file_exists(__DIR__ . "/../example.env")) {
    $dotenv = new Dotenv\Dotenv(__DIR__ . "/../example.env");
    $dotenv->load();
} else {
  echo "file does not exist";
}

$gateway = new Braintree\Gateway([
    'environment' => getenv('BT_ENVIRONMENT'),
    'merchantId' => getenv('BT_MERCHANT_ID'),
    'publicKey' => getenv('BT_PUBLIC_KEY'),
    'privateKey' => getenv('BT_PRIVATE_KEY')
]);
  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 关于#大数据#的问题:请问有人能系统得总结一下什么数据分析师,数据架构师还有开发师的具体职业要求和就业前景嘛d(ŐдŐ๑)
      • ¥15 win10账户不见了怎么找回
      • ¥15 如何显示得分大于0.5的检测框
      • ¥15 微信小游戏使用云开发的CDN配置
      • ¥15 Matlab的SAW模态耦合模型的仿真程序
      • ¥20 求个C# SSL socket的客户端和 服务端代码
      • ¥15 大家调试TI C2000系列DSP用什么上位机?
      • ¥20 Eltable 如何实现鼠标拖拽范围多选
      • ¥15 产品需要了解什么代码技术才能更好站在开发角度思考问题?
      • ¥15 统计数据能提前统计吗