2
基本上我已經成功安裝了MongoDB,它是PHP的擴展。我想在我的IDE中使用代碼完成功能來獲取MongoDB php庫,並且最近得到的答案是關於PDT和Eclipse的一些內容。我沒有得到任何地方。如何從.dll文件生成.php文件以完成代碼?
基本上我已經成功安裝了MongoDB,它是PHP的擴展。我想在我的IDE中使用代碼完成功能來獲取MongoDB php庫,並且最近得到的答案是關於PDT和Eclipse的一些內容。我沒有得到任何地方。如何從.dll文件生成.php文件以完成代碼?
好了很多搜索後,我發現一些代碼可以幫助我做到這一點!我會將代碼包含在這裏供其他人使用,以防git倉庫發生某些事情。所有你需要做的就是在類和你想存根代碼完成功能寫入到這些陣列$functions = array();
$classes = array();
https://gist.github.com/ralphschindler/4757829
<?php
define('T', ' ');
define('N', PHP_EOL);
$functions = array();
$classes = array();
$constant_prefix = 'X_';
$php = '<?php' . N;
$php .= '/**' . N . ' * Generated stub file for code completion purposes' . N . ' */';
$php .= N . N;
foreach (get_defined_constants() as $cname => $cvalue) {
if (strpos($cname, $constant_prefix) === 0) {
$php .= 'define(\'' . $cname . '\', ' . $cvalue . ');' . N;
}
}
$php .= N;
foreach ($functions as $function) {
$refl = new ReflectionFunction($function);
$php .= 'function ' . $refl->getName() . '(';
foreach ($refl->getParameters() as $i => $parameter) {
if ($i >= 1) {
$php .= ', ';
}
if ($typehint = $parameter->getClass()) {
$php .= $typehint->getName() . ' ';
}
$php .= '$' . $parameter->getName();
if ($parameter->isDefaultValueAvailable()) {
$php .= ' = ' . $parameter->getDefaultValue();
}
}
$php .= ') {}' . N;
}
$php .= N;
foreach ($classes as $class) {
$refl = new ReflectionClass($class);
$php .= 'class ' . $refl->getName();
if ($parent = $refl->getParentClass()) {
$php .= ' extends ' . $parent->getName();
}
$php .= N . '{' . N;
foreach ($refl->getProperties() as $property) {
$php .= T . '$' . $property->getName() . ';' . N;
}
foreach ($refl->getMethods() as $method) {
if ($method->isPublic()) {
if ($method->getDocComment()) {
$php .= T . $method->getDocComment() . N;
}
$php .= T . 'public function ';
if ($method->returnsReference()) {
$php .= '&';
}
$php .= $method->getName() . '(';
foreach ($method->getParameters() as $i => $parameter) {
if ($i >= 1) {
$php .= ', ';
}
if ($parameter->isArray()) {
$php .= 'array ';
}
if ($typehint = $parameter->getClass()) {
$php .= $typehint->getName() . ' ';
}
$php .= '$' . $parameter->getName();
if ($parameter->isDefaultValueAvailable()) {
$php .= ' = ' . $parameter->getDefaultValue();
}
}
$php .= ') {}' . N;
}
}
$php .= '}';
}
echo $php . N;
這編譯.PHP在所有.dll文件不是相關的。 – gustavohenke
需要對.php執行.dll的操作...爲了在NetBeans中完成代碼,只需要方法和類的接口......如果沒有它,很難工作。 :(整個API中的每個函數都需要在線查找文檔。 –