Php 将Zend rest控制器与Zend rest客户端一起使用

Php 将Zend rest控制器与Zend rest客户端一起使用,php,zend-framework,Php,Zend Framework,这是我第一次访问Zend,我面临着设置restful api的任务。我使用了zend rest控制器,其代码如下所示:- myzendrestcontroller-"localhost/alice/Theb2cController.php" <?php class Theb2cController extends Zend_Rest_Controller { public function init() { $this->_helper->viewRend

这是我第一次访问Zend,我面临着设置restful api的任务。我使用了zend rest控制器,其代码如下所示:-

myzendrestcontroller-"localhost/alice/Theb2cController.php"
<?php

class Theb2cController extends Zend_Rest_Controller
{

   public function init() {
      $this->_helper->viewRenderer->setNoRender(true);
   }

   public function indexAction() {
       $this->getResponse()
            ->appendBody($xml);
   }

   public function getAction() {
      if ($this->getRequest ()->getParam ( "name" ) != NULL) {   
         $return =" wow";
      } else {
         $return= 'no parameters!';
      }

      echo $return
   }

   public function postAction() {
       $salutation=$this->getRequest()->getParam("salutation");  
   }

   public function putAction() {
   }

   public function deleteAction() {
      $this->getResponse()
            ->appendBody("From deleteAction() deleting the requested article");
   }
}
?>  
myzendclient-"localhost/alice1/theb2cclient.php"
require_once("Zend/Rest/Client.php");
$url="localhost/alice/Theb2cController.php"
$client1=new Zend_Rest_Client($url);
$client1->name('alice');
$response=$client1->get();
echo $response;

但是我没有得到任何回应,这只是一个空白屏幕。有人能帮忙吗?首先,如果你只有一个空白屏幕,也就是说什么都没有,那么你应该看看你的错误配置。确保所有错误都显示在带有和的PHP中

第二,到处都是问题。当您将Zend_Rest_控制器作为一个独立的对象而不是整个Zend MVC框架使用时,您很可能会丢失路由器,并且控制器中的所有
$this
引用实际上毫无用处。实际上,当您调用其中一个操作时,您应该会看到错误,但您并不像我看到的那样远

Zend_Rest_控制器需要路由信息和视图来呈现文档,但是当您直接调用
Theb2cController.php
文件时,这一切显然都丢失了;包括错误报告!找到其他方法,在没有控制器信息的情况下向客户端提供有效的URL

因此,下面的方法行不通,因为您的
Theb2cController.php
实际上没有执行任何操作并返回任何内容

$url="localhost/alice/Theb2cController.php"
$client1=new Zend_Rest_Client($url);

您是使用Zend的整个MVC框架,还是仅使用Zend_Rest类作为项目中的独立对象?@Adrian我仅使用Zend Rest类当我运行restful web服务项目时,我得到的错误选择不包含任何可以在服务器上运行的资源。请帮我解决这个问题。另外,请帮助我一步一步地指导运行一个简单的web服务项目