C++ 的 PHP 扩展包装器
我是 PHP 编写扩展领域的新手,但是我需要为 C++ 到 PHP 创建一个包装类。我目前使用的是 PHP 5.2.13。我读了这篇文章 http://devzone。 zend.com/article/4486-Wrapping-C-Classes-in-a-PHP-Extension,有关如何继续包装 C++ 类以与 PHP Zend 通信的教程,但它是为 Linux 系统编写的。你们有关于如何继续编写与 PHP 通信的包装类的文章或建议吗?
I am new in this area of writing extension for PHP, however I need to create a wrapper class for C++ to PHP. I am currently using PHP 5.2.13. I read this article http://devzone.zend.com/article/4486-Wrapping-C-Classes-in-a-PHP-Extension, a tutorial on how I could proceed to wrap C++ class to communicate with PHP Zend however it is written to for linux system. Do you guys have any article or advice on how I could proceed to write a wrapper class to communicate with PHP?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这正是我最近一直在做的事情。您引用的教程是一个很好的教程(这也是我的起点)。这是我包装课程时遵循的基本流程。假设您正在包装名为
Myclass
的 C++ 类:创建 php_myclass.h:
然后在 php_myclass.cpp 中定义您的 php 类:
我希望这样示例代码可以编译,或者至少有帮助。 :) 它是根据我这里的真实工作代码匆忙拼凑而成的,如果查找/替换破坏了某些内容,至少您可能会知道该怎么做。还有很多内容,请阅读 Sara Golemon 的三部分扩展教程 http://devzone.zend .com/article/1021 了解更多信息。祝你好运。
This is exactly what I've been doing lately. The tutorial you referenced is a good one (it was my starting point as well). Here's the basic process I've followed for wrapping my classes. Say you're wrapping your C++ class named
Myclass
:Create php_myclass.h:
Then define your php class in php_myclass.cpp:
I hope this example code compiles, or at least helps. :) It was sort of hastily put together from real working code I have here, and if the find/replaces broke something, at least you might get an idea of what to do. There's plenty that's left out of this, read Sara Golemon's three-part extensions tutorial on http://devzone.zend.com/article/1021 for more. Good luck.
您会发现的最好的“文档”是 PHP 的源代码和扩展(抱歉)。您会发现,一旦您在做一些不平凡的事情,就必须深入研究源代码(尤其是 Zend 引擎的标头)。
话虽如此,您可能会发现一些对您入门有用的资源。请参阅这些文章和Sara Golemon 扩展和嵌入 PHP。另请参见 pecl.php.net/support.php
The best "documentation" you'll find is the source code of PHP and is extensions (sorry). You'll find you have to dig into the sources (especially the headers of the Zend engine) as soon as you're doing something non-trivial.
Having said this, there are a few resources you might find useful to get you started. See these articles and Extending and Embedding PHP by Sara Golemon. See also pecl.php.net/support.php