Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - Cleanup the Junk

Tags:

php

I have inherited a very messy project. There are at least 3 versions that I can tell in it.

Is there a utility that can trace the PHP code from the main index.php so that I can figure out what isn't being used and what is, or am I stuck doing a manual cleanup?

Thanks

*Update*

I don't think I've been clear about what I'm looking for, that or I'm not understanding how the products mentioned work. What I'm looking for is something that can run on a folder (directory) and step through the project and give me a report of which files are actually referenced or used (in the case of images, CSS, etc).

This project has several thousand files and it's a very small project. I'm trying to clean it up and when I do a "search in files" in my IDE I get 3 or 4 references and can't easily tell which one is the right one.

Hope that makes it a little clearer.

like image 688
John Swaringen Avatar asked Jan 28 '26 06:01

John Swaringen


2 Answers

Cross referencing software really lets you explore which functions are used for what.

PHPXref is quite good..

For example Yoast used it to cross reference the Wordpress PHP code. Take a look at the Wordpress example of how powerful it is.

For example, start by browsing the WP trunk. Click on some of the file names on the left and observe how the required files are listed, along with defined classes and methods, etc., etc.

like image 164
Peter Ajtai Avatar answered Jan 29 '26 20:01

Peter Ajtai


There are several utilities that can do this, what first comes mind is Zend Studio's built in Optimizer that will run through your files and issue notices on a per file basis, including unused variables, warnings, etc. Alternatively, you can run your program in E_STRICT and PHP will notify you of some of your issues.

like image 28
asnyder Avatar answered Jan 29 '26 18:01

asnyder