我需要为PhpDocumentor创建自定义模板.问题是template.xml,即使指定为绝对路径中定义的路径也未正确解析.PhpDocumentor在供应商目录中查找它们.
<template>
<author>Code Mine</author>
<email>office@code-mine.com</email>
<description>Template for Confluence API</description>
<version>1.0.0</version>
<transformations>
<transformation writer="twig" source="./index.html.twig" artifact="index.html"/>
<transformation query="indexes.namespaces" writer="twig" source="./namespace.html.twig" />
<transformation query="indexes.classes" writer="twig" source="./class.html.twig" />
</transformations>
</template>
Run Code Online (Sandbox Code Playgroud)
尽管twig模板位于xml引用的路径中,但我收到文件不存在的错误.
编辑:
我还尝试设置所有配置细节,phpdoc.xml希望路径将被视为相对于配置文件,但没有运气.
希望有人在这里知道一件事或两件事.
简短的问题
我在命令行上使用phpdoc遇到错误,在PHP 7.0.2上通过pear安装.错误是:
#> phpdoc
PHP Fatal error: Uncaught Doctrine\Common\Annotations\AnnotationException:
You have to enable opcache.load_comments=1 or zend_optimizerplus.load_comments=1.
in /usr/local/php5-7.0.2-20160108-102134/lib/php/phpDocumentor/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php:193
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个错误?
细节
Opcache已启用并opcache.load_comments=1位于我的opcache.ini文件中,分别使用命令:php -i | grep "Opcode"和验证php -i | grep "opcache".在该.ini文件中,我可以通过检查启用并通过该文件禁用opcache来验证是否加载了更改.
话虽如此,如果我opcache.load_comments=1在我的.ini文件中,为什么我仍然会收到此错误?
谢谢!
是否可以链接到另一个方法/类/属性/等.在我的项目里面内嵌@deprecated标签?像这样:
/**
* Method description
* @deprecated 1.0 Reason for deprecation, use {@link newMethod()} instead!
* @param string $str
* @param string|null $str2
* @return bool
*/
public function method($str, $str2) {
// TODO: Code...
}
...
Run Code Online (Sandbox Code Playgroud)
?
我开始使用phpdocumentor2进行php项目,并希望扩展它以便它具有自定义功能.
我想在默认生成的内容下输出"最新的函数/方法/类".我的想法是什么,当它的运行能够比较解析文件中的任何元素是否有新的@version或甚至文件更改日期.
有谁知道这是否可行以及如何使用此doc生成器或其他?
也有人知道当前phpdocumentator2是否正确支持@uses,如果没有,还有什么其他的解决方法可以使它工作?我需要它来连接我的项目类.
我真的很难让phpDocumentor 2工作.
我有几个程序风格的文件,必须记录.我发现这是唯一使用页面级别的docblock,但似乎它们在phpDocumentor版本2中不再正常工作.
stackoverflow上的一个相关问题表明其他人遇到了同样的问题.在这个问题中有两个建议:
namespace到应记录的文件中abstract或new-black不幸的是,我无法找到任何一个工作.
zend,abstract和new-black)与phpDoc 2的phar版本时,我得到错误PHP Warning: XSLTProcessor::transformToUri(): No stylesheet associated to this object in phar.显然这是一个已知的问题.编辑:
我更进了一步.我安装了phpDocumentor的PEAR版本,并尝试了每个可用的模板.但我还远未达到目标:生成的文档中的页面级docblock.
模板分为两类:
clean,responsive,responsive-twig和old-ocean:他们这样做所产生的文档中未输出页面级的文档块.abstract,new-black和zend:他们有一个doc by file部分,它显示了预期的文件级文档.但是他们错过了几个资源(.js文件和图像),因此它们看起来完全相同,并且无法正常工作(导航窗格没有展开 - 折叠行为).我查看了他们的git存储库,文件似乎甚至错过了.在这一点上,我只是想知道我是否正在寻找正确的方向:似乎不可思议,由于phpDocumentor 2中的主要回归和错误,不可能有文档显示文件级docblocks.
如果我真的走错了路,请建议我如何从PHP项目中获取有价值的文档.如果我走在正确的轨道上,请帮助我理解我所缺少的拼图中的重要部分.
尽管我按照说明安装了phpDocumentor,但命令行似乎没有响应 phpdoc
给定错误: 未找到命令“ phpdoc”,您的意思是:来自deb phploc的命令“ phploc”来自deb phpdox的命令“ phpdox”尝试:sudo apt install
我按照以下步骤安装了phpdoc,它似乎可以正常工作
pear channel-discover pear.phpdoc.org
pear install phpdoc/phpDocumentor
安装完成后,我尝试运行phpdoc -h,但它不起作用。
使用:7.2.16
作业系统:Ubuntu 18.04.2 LTS
感谢您提供的任何帮助。
想象一下,我们有一个带有可选的可为空参数(PHP 7.0)的方法,如下例所示:
/**
* @param Type1 $foo
* @param Type2 $bar
*/
function myFunction(Type1 $foo, Type2 $bar = null)
{
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,PHPDoc 文档并不清楚,将第二个参数标记为可选和可为空的正确方法是什么。
通常我使用“Type2|null”表示法:
/**
* @param Type1 $foo
* @param Type2|null $bar
*/
function myFunction(Type1 $foo, Type2 $bar = null)
{
}
Run Code Online (Sandbox Code Playgroud)
实际上这是我更喜欢的方式,因为它明确描述了所有可能的类型。但是我从文档中听到了不明显的抱怨,无论参数是否可选。
我知道,像接缝一样,非官方约定“(可选)”
/**
* @param Type1 $foo
* @param Type2 $bar (optional)
*/
function myFunction(Type1 $foo, Type2 $bar = null)
{
}
Run Code Online (Sandbox Code Playgroud)
我不喜欢这种方法,因为从技术上讲,您可以明确提供 NULL 作为第二个参数。从phpdoc中不清楚。
一般来说,我什至可以一起使用它们:
* @param Type2|null $bar (optional)
Run Code Online (Sandbox Code Playgroud)
但它看起来并不好看,恕我直言。
你能给我一些反馈,或者更好的是,一些指向相应编码标准/风格指南的链接吗?
我最近创建了一个用于创建HTML元素的类.我没有为每个现有的HTML元素和属性创建方法而烦恼,而是决定使用魔术方法__get和__call.所以使用我的代码我基本上可以这样做:
$signUpForm->insert->input->type('text')->name('firstName')->maxlength(100)->disabled
$signUpForm->insert->input->type('email')->name('emailAddress')->maxlength(100)
Run Code Online (Sandbox Code Playgroud)
等等
但既然我决定保持这种"神奇"和简单,我也可以这样做:
$signUpForm->insert->magic->trick('rabbit')->accessory('hat') 这将导致:
<magic trick='rabbit' accessory='hat'>
Run Code Online (Sandbox Code Playgroud)
这一切都很好,因为在我看来它削减了很多样板代码,并且正是我需要做的.我不希望一个类强制执行HTML标准,我想要一个类来促进HTML,因为你知道如何使用它(老实说,这样做的代码很小)
所以我的问题是,考虑到这个类可以接受任何未定义的属性或方法,有没有办法在PHPDoc中指定这种行为?我没有运气就尝试了以下内容:
/**
* @property HtmlElementAttribute * Insert a new HTML element attribute
* @method HtmlElementAttribute * Insert a new HTML element attribute
*/
Run Code Online (Sandbox Code Playgroud)
我不知道这只是一个PHPStorm的东西,但我找不到任何类似的场景......
此外,如果您想知道为什么我会做这样的事情,那就是跟踪我的PHP代码中的某些HTML方面(例如,在表单中声明的ID或表单内的元素).这可以让我在发送给最终用户之前在我的HTML中具有可见性.
Composer 依赖项声明它没有 php-xsl。我正在尝试安装 phpdocumentor/phpdocumentor,但由于要求它不会让我安装。所以现在我正在尝试安装要求,我得到了这个:
$ composer require phpdocumentor/template-zend
Using version ~1.3 for phpdocumentor/template-zend
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- phpdocumentor/template-zend 1.3.2 requires ext-xsl * -> the requested PHP extension xsl is missing from your system.
- phpdocumentor/template-zend 1.3.1 requires ext-xsl * -> the requested PHP extension xsl is missing from your system.
- phpdocumentor/template-zend 1.3.0 requires ext-xsl …Run Code Online (Sandbox Code Playgroud) 在http://www.phpdoc.org/的主页上,在http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_phpDocumentor.quickstart.pkg.html和https://github.com上/ phpDocumentor/phpDocumentor2,安装phpDocumentor的说明是:
pear channel-discover pear.phpdoc.org
pear install phpdoc/phpDocumentor
Run Code Online (Sandbox Code Playgroud)
当我这样做时,我发现它已被弃用:
[root@desktop ~]# pear channel-discover pear.phpdoc.org
Adding Channel "pear.phpdoc.org" succeeded
Discovery of channel "pear.phpdoc.org" succeeded
[root@desktop ~]# pear install PhpDocumentor
WARNING: "pear/PhpDocumentor" is deprecated in favor of "phpdoc/phpdocumentor"
Did not download optional dependencies: pear/XML_Beautifier, use --alldeps to download automatically
pear/PhpDocumentor can optionally use package "pear/XML_Beautifier" (version >= 1.1)
downloading PhpDocumentor-1.4.4.tgz ...
Starting to download PhpDocumentor-1.4.4.tgz (1,534,088 bytes)
..............................................................................................................................................................................................................................................................................................................done: 1,534,088 bytes
install ok: channel://pear.php.net/PhpDocumentor-1.4.4
[root@desktop ~]# pear …Run Code Online (Sandbox Code Playgroud) 我正在将我的项目升级到 PHP 8.0+。到目前为止,在代码注释中,我使用了@param和@return标签,如“选项 1”,而不是“选项 2”:
选项1:
@param string[] ...。@return User[] ...。选项2:
@param array ...。@return array ...。不过,因为我不知道第一种形式是否被官方允许,所以我开始问自己,切换到第二种形式是否会更好......所以,我想问你:有吗?有没有可用的 PHP 代码文档官方PHPDoc 参考资料?
另外,是否建议使用第一个选项而不是第二个选项?换句话说:是否有任何反对的论据——也考虑到未来?
感谢您的时间。
PS :我找到了PHPDocumentor的参考资料,但我有一种感觉,它不是官方的 PHP 参考资料,而且还不兼容 PHP 8.0+。
我想在我的SF2项目中安装包phpdocumentor/reflexion.所以我运行以下命令,composer require "phpdocumentor/reflection"但我有以下堆栈错误:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Conclusion: don't install phpdocumentor/reflection 3.0.1
- Conclusion: remove phpdocumentor/reflection-docblock 3.1.1
- Installation request for phpdocumentor/reflection ^3.0 -> satisfiable by phpdocumentor/reflection[3.0.0, 3.0.1]. ? Feature/T4136-18-identification-by-vin
- Conclusion: don't install phpdocumentor/reflection-docblock 3.1.1
- phpdocumentor/reflection 3.0.0 requires phpdocumentor/reflection-docblock ~2.0 -> satisfiable by phpdocumentor/reflection-docblock[2.0.0, 2.0.0a1, 2.0.0a2, 2.0.0a3, 2.0.1, 2.0.2, 2.0.3, 2.0.4]. ? master
- Can only install one of: phpdocumentor/reflection-docblock[2.0.0, 3.1.1].
- Can only install …Run Code Online (Sandbox Code Playgroud) php ×12
phpdocumentor2 ×12
phpdoc ×9
composer-php ×2
centos ×1
docblocks ×1
opcache ×1
pear ×1
php-7 ×1
php-7.2 ×1
phpstorm ×1
twig ×1
ubuntu-18.04 ×1