列出代码库中使用的 PHP 模块
我需要列出给定代码库所需的所有 PHP 扩展。 解决这个问题的最佳方法是什么?
我最初的想法是编写一个脚本来遍历所有文件并查找所有函数并将它们与给定的扩展/函数数据库进行比较。还有其他建议吗?
更新:我已经使用 grep 和 get_loaded_modules、get_extension_funcs PHP 函数编写了一些 Bash 脚本,但这个扩展正是我正在寻找的。
I need to list all PHP extensions that's required by a given code base.
What would be the best way to tackle this problem?
My initial thought is to write a script that goes through all files and find all functions and compare them to a given extension/function database. Any other suggestions?
Update: I already did some Bash script with grep and using get_loaded_modules, get_extension_funcs PHP functions, but this extension is exactly what I was looking for.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一旦您学会了如何使用 PHP CompatInfo(不是 PEAR 扩展),它就非常有用:
的新文件中以下命令(当前目录是放置 phpcompatinfo.json 的目录)
phpcompatinfo 分析器:运行。扩展
您将得到如下输出:
PHP CompatInfo (not the PEAR extension) is great once you learn how to use it:
run the following command (current dir being the directory where phpcompatinfo.json is placed)
phpcompatinfo analyser:run . extension
You will get an output like this:
据我所知,有一个 PEAR 包可以做到这一点:
PHP_CompatInfo
:请参阅命令行解析器 了解如何从命令行运行它,并获取一些输出示例。
(它被标记为不再维护,所以最近版本的 PHP 可能会出现一些问题,但我上次使用它时——也许是一年前——它工作得很好)
There is a PEAR package that does that, from what I remember :
PHP_CompatInfo
:See The Command-Line Parser to know how to run it from the Command Line, and to get some examples of output.
(It's marked as not maintained anymore, so there might be some troubles with recent versions of PHP, but last time I used it -- maybe one year ago -- it worked fine)
作为 PHP CompatInfo 的替代方案,我为 PHP 7 开发了一个工作原理类似的工具。它没有提供与 CompatInfo 一样详细的信息,但它列出了您的项目所需的扩展。
请参阅: https://github.com/RogerGee/php-ext-depends
示例用法:
As an alternative to PHP CompatInfo, I've developed a tool for PHP 7 that works similarly. It doesn't provide as much detailed information as CompatInfo, but it does list the extensions required by your project.
See: https://github.com/RogerGee/php-ext-depends
Example usage: