Stripe API Recurring Payment: 'Fatal error: Uncaught Error: Class "Dotenv\Dotenv"'
Stripe API Recurring Payment: 'Fatal error: Uncaught Error: Class "Dotenv\Dotenv"'
我是一个新手,我只是将教程和用例拼凑在一起以加快我对这个新领域的理解,所以很抱歉不知道发生了什么。
无论如何,情况是这样的:我正在使用 xampp 作为测试服务器来创建一个数据库驱动的网站,其中包括登录页面、搜索页面和个人资料页面,您可以在其中订阅定期订阅使用 Stripe 的 API.
的包
按照 Stripe 的说明进行操作:https://stripe.com/docs/billing/subscriptions/checkout, I copied all the code from Github 完成第 4 步并刷新索引页面,看看是否发生了什么。我最终收到此错误:
Fatal error: Uncaught Error: Class "Dotenv\Dotenv" not found in C:\xampp\root\index.php:15
我使用 windows 安装程序下载了 composer,之后,我通过在命令终端中输入 'composer' 来验证它是否正常工作。在这一点上,我不确定发生了什么。在vendor目录下,symfony、stripe和composer都有自己的文件夹。
有人可以帮忙吗?
<?php
include "db_connect.php";
include "header.php"; //just some script and style sources, as well as the upper half of the html body tag
require_once("stripe-php/init.php");
use Slim\Http\Request;
use Slim\Http\Response;
use Stripe\Stripe;
require 'C:/Users/USER/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::create(__DIR__);
$dotenv->load();
您看到该错误的原因是您只复制了 index.php
代码,该代码并非设计用于孤立工作。该代码具有依赖项,其中之一是 Dotenv
,需要使用 Composer 安装。
为了使示例代码正常工作,您需要下载所有代码并遵循 the instructions noted in the php-slim
folder:
- 运行
composer install
安装依赖项
- 在本地启动测试PHP服务器:
php -S localhost:4242 index.php
- 在浏览器中打开 http://localhost:4242
我是一个新手,我只是将教程和用例拼凑在一起以加快我对这个新领域的理解,所以很抱歉不知道发生了什么。
无论如何,情况是这样的:我正在使用 xampp 作为测试服务器来创建一个数据库驱动的网站,其中包括登录页面、搜索页面和个人资料页面,您可以在其中订阅定期订阅使用 Stripe 的 API.
的包按照 Stripe 的说明进行操作:https://stripe.com/docs/billing/subscriptions/checkout, I copied all the code from Github 完成第 4 步并刷新索引页面,看看是否发生了什么。我最终收到此错误:
Fatal error: Uncaught Error: Class "Dotenv\Dotenv" not found in C:\xampp\root\index.php:15
我使用 windows 安装程序下载了 composer,之后,我通过在命令终端中输入 'composer' 来验证它是否正常工作。在这一点上,我不确定发生了什么。在vendor目录下,symfony、stripe和composer都有自己的文件夹。
有人可以帮忙吗?
<?php
include "db_connect.php";
include "header.php"; //just some script and style sources, as well as the upper half of the html body tag
require_once("stripe-php/init.php");
use Slim\Http\Request;
use Slim\Http\Response;
use Stripe\Stripe;
require 'C:/Users/USER/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::create(__DIR__);
$dotenv->load();
您看到该错误的原因是您只复制了 index.php
代码,该代码并非设计用于孤立工作。该代码具有依赖项,其中之一是 Dotenv
,需要使用 Composer 安装。
为了使示例代码正常工作,您需要下载所有代码并遵循 the instructions noted in the php-slim
folder:
- 运行
composer install
安装依赖项 - 在本地启动测试PHP服务器:
php -S localhost:4242 index.php
- 在浏览器中打开 http://localhost:4242