3

Please see my current file structure

CakePHP
  - bin
  - config
  - src
  - vendor
  - webroot


RowPHP
  - push.php

I want to import/include Push class into my cakephp2 application which stands at push.php file outside of cakephp

Which I have tried

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

it include successfully but when I try to create a object it through error

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

Question: How to import/include this class into my cakephp application ?

tarikul05
  • 1,843
  • 1
  • 16
  • 24

1 Answers1

1

You need to ensure PHP can find the class in the correct namespace using new \Push() (note the backslash before the class name):-

require_once( ROOT . DS . '..' . DS . 'RowPHP'. DS . 'push.php');
$pushOb = new \Push();
drmonkeyninja
  • 8,490
  • 4
  • 31
  • 59