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(
: mysqliimagecreate(
or imagepng
or imagejpeg
or ... : gdcurl_init(
: curlDoes a similar script already exist? If not, would it make sense to write it?
Writing as answer as requested by OP in their comment
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;
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