Class 在 CakePHP shell 脚本中找不到

Class not found in a CakePHP shell script

我试图在 CakePHP 的 shell 脚本中包含一些 classes,但它们似乎无法加载。

例如我有一个 class 位于

/app/Lib/php-ews/EWSType/FindItemType.php

我的脚本如下所示:

App::uses('FindItemType', 'Lib/php-ews/EWSType');

class TestShell extends AppShell {  

    public function main() {
        $this->out($this->readbox());
    }

    public function readbox() {
        $request = new EWSType_FindItemType();
    }
}

这给出了一个错误:

"PHP Fatal error:  Class 'EWSType_FindItemType' not found in "

不确定我做错了什么。

PHP Exchange Web 服务应安装在 Vendor 文件夹中并通过 App::import().

加载

来自蛋糕PHP 2.x docs:

Your vendor files may not follow conventions, have a class that differs from the file name or does not contain classes. You can load those files using App::import().

你的情况:

App::import('Vendor', 'FindItemType', array('file' => 'php-ews/EWSType/FindItemType.php'));