Answer the question
In order to leave comments, you need to log in
PHP script - determining the necessary extensions
The task is simple and banal:
A new server with a clean installation of php.
The script actively uses all sorts of goodies such as SOAP, json_encode and other benefits of civilization.
You need to install only the necessary extensions.
The solution that I came up with:
1) On a server with a full stuffing of extensions, where the script will work 100%, we make a list of available ones ( get_loaded_extensions ).
2) We make a list of functions and constants for each ( get_extension_funcs , get_defined_constants )
3) Search for these functions and constants in the project (find, grep and other perversions)
4) We have a ready list of necessary extensions.
Minus: extensions that add only classes (xmlreader for example) will not be identified, because. classes will not be included in the output of get_extension_funcs
Is there an out-of-the-box solution for auditing the code and compiling a list of required extensions? Or how can this problem be solved in another way?
Answer the question
In order to leave comments, you need to log in
And here is the Static Analysis of PHP Code with HipHop variant .
Because there is an attempt to compile - all branches are viewed de facto.
Scheme: Turn off everything, compile, catch the error, turn on the right one.
The disadvantages are obvious - build hiphop, set up an automated compilation environment and enable / disable modules. Not the fact that it will compile your project at all.
About the minuses you indicated: look towards get_declared_classes and get_class_methods .
If you have an OOP application, then you can try the following method:
0. Disable all extensions in php.ini.
1. We make a list of all PHP extensions in the form of an array, set our own error handler via ua.php.net/manual/en/function.set-error-handler.php.
2. We load all extensions in runtime using php.net/manual/en/function.dl.php
3. We load all classes, all files that we can.
4. Repeat steps 2-3, one by one without loading one of the extensions. If an exception or an error crashes, it means that an unloaded extension is being used.
The coverage is of course not 100%. it will not be possible to load all the files (in the same views, if they are directly loaded, errors will fall).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question