I have a model in src\Front\Model\FrontModel.php
I am trying to extend it in my IndexController i have this in my Module.php:
use Front\Model\FrontModel;
But i always get this error:
Fatal error: Class 'Front\Model\FrontModel' not found in
C:\Apache24\htdocs\cartbiz\module\Front\src\Front\Controller\IndexController.php on line 16
I have this in my IndexController where i am trying to extend my model my Controller resides in src\Front\Controller\IndexController.php
namespace Front\Controller;
use Front\Model\FrontModel;
class IndexController extends FrontModel
{
/* Initialize Controller */
public function initAction()
{
parent::initAction();
}
}
I have this as my model class my model class resides in src\Front\Model\FrontModel.php
namespace Front\Model\FrontModel;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
class FrontModel extends AbstractActionController
{
/* Application initializer
** All front application logic
*/
public function __construct ()
{
die('ssss');
$this->_viewManager=new ViewModel;
$this->_viewManager->setTemplate('front/index/index');
return $this->_viewManager;
}
}
Any help is appreciated
namespace
statement written in thesrc\Front\Model\FrontModel.php
file? i.e. above theclass FrontModel extends AbstractActionController
line. – Kunal DetheFrontModel
class is using the namespaceFront\Model\FrontModel
while it should beFront\Model
your controller is looking forFront\Model\FrontModel
class but with your setup you should:use Front\Model\FrontModel\FrontModel
in your controller as it doesn't know the class, since you're currently using a namespace. I'm not creating a new answer as @AlexP is already covering it. – Kwido