Class not found in a CakePHP shell script

I'm trying to include some classes in my shell script in CakePHP but they don't seem to load.

For example I have a class located in

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

My script looks like this :

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();
    }
}

This gives an error:

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

Not sure what I'm doing wrong here.

Answers


PHP Exchange Web Services should be installed in the Vendor folder and loaded via App::import().

From the CakePHP 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().

In your case:

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

Need Your Help

DocumentBuilder doc (with root element) outputs null even though root element is appended

java xml dom javax.xml

I'm attempting to have it return my empty root element with attributes but am getting [#document: null] output. Am I absolutely required to have a child element for the root?

orientation bug with -webkit-overflow-scrolling : touch

css ios5 webkit scroll mobile-safari

I have been playing around with -webkit-overflow-scrolling:touch; for a while and I getting randomly the following problem: