将子类与 Zend_Rest_Server 一起使用
可悲的是,Zend_Rest_Server 和 Zend_Rest_Client 的文档记录不足,因此我不断遇到这些令人麻木的恼人问题。
因此,为了简化我的 API 方法,我将调用 Zend_Rest_Server() ,然后将服务器类设置为“X”,这反过来又会扩展我的“api_server”类。在我的 api_server 类中,我会放置诸如身份验证、哈希密钥处理之类的内容。
但是一旦我使用“class mdb extends api_server {”而不是“class mdb {”,我的整个api应用程序就会死掉。没有错误。日志中什么也没有。无输出。这是代码:
$server = new Zend_Rest_Server();
$server->setClass("mdb");
$server->handle();
class mdb extends api_server { .... }
一旦我删除整个“extends api_server”,它就会工作(虽然我没有任何服务器的身份验证方法,所以它失败了,但服务器正在运行并响应..
所以是这样的Zend_Rest_Server() 的某种未记录的限制还是我做了一些非常愚蠢的事情?
它似乎与自动加载无关,即使我需要保存 api_server 类的文件,它也不会 工作。
Zend_Rest_Server and Zend_Rest_Client is pathetically under-documented, so I keep running into these mind numbingly irritating problems.
So, in order to streamline my API methods I would invoke Zend_Rest_Server() and then set the server class to "X", which in turn would extend my "api_server" class. And in my api_server class would I put things like authentication, hash key processing and all that stuff.
But as soon as I use the "class mdb extends api_server {" instead of just "class mdb {" my entire api application dies. Without an error. Nothing in the logs. no output. Here is the code:
$server = new Zend_Rest_Server();
$server->setClass("mdb");
$server->handle();
class mdb extends api_server { .... }
And as soon as I remove the entire "extends api_server" it will work (although I don't have any authentication methods for the server, so it fails, but the server is running and responds..
So is this some sort of undocumented limit of Zend_Rest_Server() or am I doing something really stupid?
It doesn't seem to be about about autoloading, even if I require the file that the api_server class is kept in, it won't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然,如果你扩展另一个类,你需要先定义它,所以正确的语法是:
Apparently, if you extend another class, you need to define it first, so the correct syntax would be: