我的代码很简单,但是很密集。我想将它编译成 PHP 扩展。最简单/最佳的做法是什么?
我有 Java 背景,所以编写 C / C++ 代码应该不是问题。然而,我希望避免一路上出现任何陷阱。
我找不到简单的教程或演练。有很多例子,但没有任何针对新手的例子。
这看起来是一条比我更艰难的道路,尤其是所有可爱的 C 怪癖。
I have code that is straight forward, but intensive. I would like to compile it into a PHP extension. What is the simplest / best practice for going about that?
I have a Java background, so writing the C / C++ code shouldn't be an issue. I would, however, like to avoid any pitfalls along the way.
A simple tutorial or walk through is something I haven't been able to find. Plenty of examples, but nothing aimed at someone new to doing this.
It looks like a more arduous road then I though, especially with all the lovely C quirks.
发布评论
评论(3)
PHP 手册 和此 Zend 文章 似乎涵盖了有关编写 PHP 扩展的相当多的基础知识。
The PHP Manual and this Zend article seem to cover quite a bit of ground in regards to writing PHP extensions.
标签信息
php-extension
特别是 这个答案,也从那里链接。The the tag info for
php-extension
and in particular, this answer, also linked from there.您应该尝试使用 SWIG 为源代码生成包装器,然后创建扩展。它支持Java、C/C++等多种语言,并使其尽可能简单。
You should try SWIG for generating wrapper for your source code, and then create your extension. It supports various languages like Java, C/C++ and makes it as simple as possible.