我的Customer类有问题。它在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} 第122行/home/osconliz/public_html/Osconlizapicall/api.php投放
我的客户类 - 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