I have been giving a PHP program to work on. However, this program has been worked on for years by several diffrent people. Things have been removed and added over time. But most of the files are still there.
I was wondering is there is a tool out there that can analyze a PHP program. feed it index.php for example and this tool will check and see witch files are called and used so i can remove all the dead wood that is no longer beeing used.
I was planning on writing it myself, but someone else might already have done something like this.
Any suggestions are welcome, Thx! Mike
As deceze mentioned you cannot guarantee to find all referenced files as they may be dependent on user input. However the simplest way is to use a grep tool (there is a "windows grep" application you can download, if that's your platform) and find all occurrences of "include" and "require". If you come accross the situation mentioned by deceze (include or require followed by a variable name) the file needs manual inspection, but if there is a file name specified, you can add that to the "used list".
Perhaps not the most effective solution, but fast and intuitive.
You have couple options, one to use xdebug and basically debug your application, while you are stepping through you ll find the files being used.
Another is brute force:)) start deleting files one by one and check the app if it s broken or not. if there is a lot to test, this might take a while.
And if you are searching for an app, search for dependency checker, there are corps that uses these kinda apps to check dependencies between services, like amazon.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With