我的问题是我写了休息控制器就像例如在link here.
中My Bootstrap看起来像这样
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected function _initDoctype()
{
$this->bootstrap('view');
$view = $this->getResource('view');
$view->doctype('XHTML1_STRICT');
}
protected function _initDatabase()
{
// get config from config/application.ini
$config = $this->getOptions();
$db = Zend_Db::factory($config['resources']['db']['adapter'], $config['resources']['db']['params']);
//set default adapter
Zend_Db_Table::setDefaultAdapter($db);
//save Db in registry for later use
Zend_Registry::set("db", $db);
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', 'on');
}
protected function _initAutoload()
{
$modeloader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => APPLICATION_PATH));
$auth =Zend_Auth::getInstance();
$acl =new Model_LibraryAcl;
$fc=Zend_Controller_Front::getInstance();
$fc->registerPlugin(new Plugin_AccessCheck($acl,$auth));
return $modeloader;
}
public function _initGlobalsetting()
{
define('SITE_URL', "http://".$_SERVER['HTTP_HOST']);
}
protected function _initAutoloader()
{
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace("Api"); // or Example_
}
public function _initfileUpload()
{
define('PUBLIC_PATH', realpath(dirname(__FILE__)));
}
protected function _initRestRoute()
{
$this->bootstrap('frontController');
$frontController = Zend_Controller_Front::getInstance();
$restRoute = new Zend_Rest_Route($frontController, array() , array('controller' =>array('ApiController')));
$frontController->getRouter()->addRoute('rest', $restRoute);
}
}
?>
即使我从Bootstrap中删除了_initRestRoute()
的条目。它正常工作然后休息控制器的用途。我正确地实施了吗?
链接到我的代码: how to call restful zend controller usin curl in php?