php - PHP 致命错误:调用未定义的“客户”类
问题描述
我的客户课程有问题。它在 POSTMAN 中返回 500 内部服务器错误,但是当我检查错误日志时,我发现了错误,现在我不确定发生了什么。这是错误:
未捕获的错误:在 /home/osconliz/public_html/Osconlizapicall/api.php:122 中找不到类“客户”
堆栈跟踪:
#0 [内部函数]:Api->create_insert_new_delivery()
#1 /home/osconliz/public_html/Osconlizapicall /rest.php(42): ReflectionMethod->invoke(Object(Api))
#2 /home/osconliz/public_html/Osconlizapicall/index.php(4): Rest->processApi()
#3 {main} 抛出 / home/osconliz/public_html/Osconlizapicall/api.php 在第 122 行
我的客户类 -customers.php
class Customer {
private $shipping_fee;
private $pickup_fee;
function setShipping_fee($shipping_fee){
$this->shipping_fee = $shipping_fee;
}
function getShipping_fee() {
return $this->shipping_fee;
}
function setPickup_fee($pickup_fee){
$this->pickup_fee = $pickup_fee;
}
function getPickup_fee() {
return $this->pickup_fee;
}
public function insertNewDelivery(){
//SOME MINOR PHP validation code
}
}
我的 api.php
<?php
class Api extends Rest {
public $dbConn;
public function __construct(){
parent::__construct();
$db = new DbConnect;
$this->dbConn = $db->connect();
}
public function create_insert_new_delivery() {
$payment_method = $this->validateParameter('shipping_fee', $this->param['shipping_fee'], STRING, true);
$date_of_delivery = $this->validateParameter('pickup_fee', $this->param['pickup_fee'], STRING, true);
try {
$token = $this->getBearerToken();
$payload = JWT::decode($token, SECRETE_KEY, ['HS256']);
$cust = new Customer; //LINE 122 ON api.php
} catch (Exception $e) {
$this->throwError(ACCESS_TOKEN_ERRORS, $e->getMessage());
}
我怀疑发生错误的行:
$cust = new Customer; //LINE 122 ON api.php before stack trace - Uncaught Error: Class 'Customer' not found in /home/osconliz/public_html/Osconlizapicall/api.php:122
解决方案
推荐阅读
- html - 小型设备上的 Bootstrap 4 菜单
- qt - 无法在 Qt Quick 项目中使用设计模式
- android - 如何在动画正在进行时停止事件?
- java - 如何在多个服务中使用调度程序?
- python - Tensorflow:如何在模型中添加正则化
- angular - Angular Material - Chips Autocomplete - 如何显示所需的错误消息和错误突出显示颜色
- php - 我无法上传 .JPG 文件,但可以在 PHP 中上传 .jpg 文件
- python - 如何从 2D numpy (lat,lon) 数组中删除扇区/切片?
- sql - 为什么 ORACLE TO_DATE 函数在传递空格时不会在 OR 条件下给出 ORA-01841 错误?
- java - 在创建之前向 Channel 添加属性