I have the following folder structure
Controller
- MainController.php
Model
- FolderA
- FolderAA
- ModelA.php
- FolderAB
- ModelA.php
And the FolderA/FolderAA/ModelA.php file is the following -
<?php
namespace Model\FolderA\FolderAA;
class ModelA extends \AppModel{
public $useTable = false;
public function test(){
$return_data['success'] = $this->success;
$return_data['message'] = $this->message;
return $return_data;
}
}
And the FolderA/FolderAB/ModelA.php file is the following -
<?php
namespace Model\FolderA\FolderAB;
class ModelA extends \AppModel{
public $useTable = false;
public function test(){
$return_data['success'] = $this->success;
$return_data['message'] = $this->message;
return $return_data;
}
}
And in the MainController.php file, I’m trying to do the following -
try{
$ModelA = new \Model\FolderA\FolderAA\ModelA();
$result = $ModelA->test();
if($result['success'] !== true){
$this->set_request_status(false, $result['message']);
}
}catch(Exception $e){
$e->getMessage();
exit();
}
I’m getting the following error fatal error -
Error: Class 'Model\FolderA\FolderAA\ModelA' not found
What am I doing wrong?
This is an attempt to organise my code into folders so that it becomes easier to maintain. I can make the name of the actual ModelFile - FolderAFolderAAModelAA.php and put that into the Model folder, but I’ll have many such folders and sub folders that having all of them in a single folder level will be very hard to manage. I did read that CakePHP 2.0 allows you to organise model files into folders - http://cakebaker.42dh.com/2007/11/22/organizing-your-code-with-folders/
Thank you in advance for your time and assistance.
Regards,
Prathamesh.