首页 > 解决方案 > 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  

标签: php

解决方案


推荐阅读