Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 对未定义方法的调用_Php - Fatal编程技术网

Php 对未定义方法的调用

Php 对未定义方法的调用,php,Php,我在这里遇到了相当的情况,我的代码在开发环境中没有遇到任何问题,但是当我将其部署到生产环境中时,出现了一些问题,告诉我类的方法没有定义。在生产中检查,代码是否存在PHP版本与我们在开发中使用的版本相同 错误消息:调用未定义的方法Action\Supplier\ShipmentController::getOverview() 类别定义: namespace Action\Supplier\Shipment; class ShipmentController extends Controlle

我在这里遇到了相当的情况,我的代码在开发环境中没有遇到任何问题,但是当我将其部署到生产环境中时,出现了一些问题,告诉我类的方法没有定义。在生产中检查,代码是否存在PHP版本与我们在开发中使用的版本相同

错误消息:调用未定义的方法Action\Supplier\ShipmentController::getOverview()

类别定义:

namespace Action\Supplier\Shipment;


class ShipmentController extends Controller
{

    protected $service;

    public function __construct(OrderServiceInterface $service)
    {
        parent::__construct();

        $this->service = $service;
    }

    //Other methods defined, they are properly terminated.

    public function getOverview() {
        //logic
    }
}
控制器类:

class Controller
{
    protected $templates;

    protected $databaseConnection;

    protected $logged;

    /**
     * Controller constructor.
     */
    public function __construct()
    {
        $this->templates = new Engine();
        $this->templates->loadExtension();
    }

    public function getTemplates()
    {
        return $this->templates;
    }

    public function setTemplates($templates)
    {
        $this->templates = $templates;
        return $this;
    }

    public function getDatabaseConnection()
    {
        return $this->databaseConnection;
    }

    public function setDatabaseConnection($databaseConnection)
    {
        $this->databaseConnection = $databaseConnection;
        return $this;
    }

    public function getLogged()
    {
        return $this->logged;
    }

    public function setLogged()
    {
    }

    protected function setHttpStatus()
    {
    }
}
类的用法:

use Action\Supplier\Shipment\ShipmentController;


$service    = new IrreleventClass();
$controller = new ShipmentController($service);
$controller->getOverview();

编辑:在评论中回答。

共享您的
控制器
类代码重新启动您的Web服务器服务,如apache和php fpm。这将清理OP缓存。@MarkusZeller几分钟前才发现这确实是一个缓存问题,谢谢!共享您的
控制器
类代码重新启动您的Web服务器服务,如apache和php fpm。这将清理OP缓存。@MarkusZeller几分钟前才发现这确实是一个缓存问题,谢谢!