How to include a class from outside the cakephp folder

See my current file structure

CakePHP
  - bin
  - config
  - src
  - vendor
  - webroot


RowPHP
  - push.php

      

I want to import/include

Push a class to my cakephp2 application which is in push.php file outside cakephp

What i tried

require_once( ROOT . DS . '..' . DS . 'RowPHP'. DS . 'push.php');
$pushOb = new Push(); 

      

it turns on successfully, but when i try to create an object via error

Fatal error: Class 'App \ Controller \ Push' not found

Question: How can I import / include this class in my cakephp application?

+3


source to share


1 answer


You need to make sure PHP can find the class in the correct namespace using new \Push()

(note the backslash in front of the class name): -



require_once( ROOT . DS . '..' . DS . 'RowPHP'. DS . 'push.php');
$pushOb = new \Push();

      

0


source







All Articles