我正在用Phalcon Zephir做一些实验,看看它能把我的一些库转换成PHP扩展的效果如何。
我有两个PHP类,每个类都已经在自己的文件中定义了: Zephir注释非常清楚,必须是这样的。
trienode.zep
namespace tries;
class trienode
{
public children;
public valueNode = false;
public value = null;
public function __construct()
{
let this->children = [];
}
}和
trie.zep
namespace tries;
class trie {
private trie;
public function __construct() {
let this->trie = new trienode();
}
}但是,每当我试图使用zephir compile编译类时,我就会得到
Warning: Class "trienode" does not exist at compile time in /home/vagrant/ext/tries/tries/trie.zep on 8 [nonexistent-class]
let this->trie = new trienode();
---------------------------------------^(如果我继续完成构建过程,并安装生成的.so文件,那么当我试图在PHP脚本中使用它时,它会出错)
<?php
namespace tries;
$test = new trie;给予
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/tries.so' - /usr/lib/php5/20121212/tries.so: undefined symbol: zephir_tries_trie_init in Unknown on line 0
PHP Fatal error: Class 'tries\trie' not found in /home/vagrant/triesTest.php on line 5我已经查看了Zephir文档和各种博客文章,但是找不到构建一个包含多个类文件的扩展名的例子。
是否有人成功地使用Zephir构建了一个包含多个类的扩展?如果是这样的话,它需要哪些设置或配置选项(或附加步骤)来构建工作状态?
发布于 2014-01-25 11:07:28
该名称空间似乎必须包含在调用中。
let this->trie = new tries\trienode();
// ^^^^^^我没有在文档中显式地看到这一点,但是在返回类型提示部分中暗示了(原谅双关语),它在提示中使用了名称空间。
将示例类更改为上面所示的类允许扩展按需要进行编译。
https://stackoverflow.com/questions/21349489
复制相似问题