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
You need to add a namespace
to the FontModel
class.
namespace Front\Model;
use Zend\Mvc\Controller\AbstractActionController;
class FrontModel extends AbstractActionController
{}
Also, it's worth noting that your naming conventions could lead to confusion. I would recommend placing all the controllers in the controller folder, and reading up on the coding standards .
Tested and works
namespace Front\Model;
use Zend\Mvc\Controller\AbstractActionController;
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;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.