Issue
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 ?
Solution
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();
Answered By - drmonkeyninja
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.