donglan6967 2015-12-02 11:11
浏览 86
已采纳

如何自动确定项目使用哪些PHP扩展?

Is there a way to automatically find out which PHP extensions are used by a particular project you have the source code of?

When migrating a website from a one server to another, I often find myself wondering what PHP extensions should I enable for the website to function normally. Yes, this use case would probably be irrelevant if the project used Docker or had an exhaustive install guide, but it's not always the case.

I was thinking of a script that went through all of the .php files and looked for specific function calls or classes, for exeample:

  • new mysqli( or mysqli_connect(: mysqli
  • imagecreate( or imagepng or imagejpeg or ... : gd
  • curl_init( : curl

Does a similar script already exist? If not, would it make sense to write it?

  • 写回答

1条回答 默认 最新

  • dongxun1244 2015-12-02 14:42
    关注

    Writing as answer as requested by OP in their comment

    glenscott/php-dependencies

    Although not a complete solution, this will lessen the manual work you'll have to do: https://github.com/glenscott/php-dependencies

    A few caveats are;

    • Your source code and its dependencies must lie under one directory -- included/required files outside this directory are not scanned
    • As it stands, only function dependencies are found. This means that class dependencies are not checked.

    You can read the blog post by the author here: http://www.glenscott.co.uk/blog/finding-function-dependencies-in-your-php-applications/

    To run

    You can do these via the command line or through a web browser.

    • Step 1) Getting PHP environment details: php get-env-functions.php

    • Step 2) Find dependencies: php scan-dependencies.php

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟
  • ¥15 树莓派控制机械臂传输命令报错,显示摄像头不存在
  • ¥15 前端echarts坐标轴问题
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题