I have been working on a small php app (400K total). But in the process of building and learning I have a lot of junk files.
I didn’t do my job and name them properly, ie demo1.php ect…
Is there a way to do dependency checking? Or is it just delete, refresh and repeat? Then undelete when needed?
There’s no magic tool that will do this for you, there’s only functionality that will help you implement your own solution.
The function you want is
This will return an array of any file that’s been included so far. Put this at the end of your bootstrap file (or at the end of all your individual files) and you can get a list of every file that’s been included or required. This will NOT report on files opened with
file_get_contents,fopen, etc. That’s why its a good idea to have some kind of wrapper functions/classes that will call these functions for you (allowing you to hook into the actions if need be)The approach I’d take it to add in code that logs the included files somewhere and then let your app run for a day or two (or exercise all its functionality yourself) This should give you a complete list of files that your project is actually using, allow you to clean up files that don’t appear on the list. This logging could be as simple as