我有一個問題,裏面的模型,我似乎無法脫身:的Zend:控制器正在尋找控制器文件夾
我有一個控制器,它看起來像這樣
namespace Restapi\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\Db\TableGateway\TableGateway;
class AdminController extends AbstractActionController
{
public function indexAction()
{
$this->getAllCountries();
return new ViewModel();
}
public function homeAction()
{
return new ViewModel();
}
protected function getAllCountries()
{
$sm = $this->getServiceLocator();
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$resultSetPrototype = new \Zend\Db\ResultSet\ResultSet;
$resultSetPrototype->setArrayObjectPrototype(new Restapi\Model\Country);
$tableGateWay = new Zend\Db\TableGateway\TableGateway('country', $dbAdapter, null, $resultSetPrototype);
$countryTable = new Model\CountryTable($tableGateWay);
var_dump($countryTable->fetchAll());
}
}
哪應該在「Restapi/Model」文件夾中調用「Country」類。
但我有一個錯誤,當我嘗試使用誰調用模型的方法:
"Fatal error: Class 'Restapi\Controller\Restapi\Model\Country' not found in D:\Web\Code\ZendRest\module\Restapi\src\Restapi\Controller\AdminController.php on line 28".
Zend的絕對想找在Controller文件夾中的模型。有人知道爲什麼以及如何解決這個問題?
感謝您的幫助,我已經嘗試過,但沒有改變任何事情。 並進一步,如果我評論說,呼籲國家示範線路,問題繼續與TableGateway: 「致命錯誤:類‘RESTAPI \控制器\ Zend的\ DB \ TableGateway \ TableGateway’不在第30行找到D:\ Web \ Code \ ZendRest \ module \ Restapi \ src \ Restapi \ Controller \ AdminController.php「 我同意問題是關於命名空間,但我不知道它在哪裏來自。 – Lazyrocker
對不起它的工作很好,我只是用錯了 $ tableGateWay =新的Zend \ DB \ TableGateway \ TableGateway 同時使用使用Zend的\ DB \ TableGateway \ TableGateway ;, 感謝很多:) – Lazyrocker