Page 1 of 1
Tracking include and require statements
Posted: Fri May 29, 2009 4:57 pm
by MmmVomit
I'm working on trimming away old and unused scripts from a rather large project. The only problem is that we have a real tangle of include and require statements.
I can gather statistics from Apache's log files to help identify pages that aren't being directly accessed by users, but when one file is included by another, that's all being done by PHP, right? Is there any way to create a log of the files that PHP accesses?
Re: Tracking include and require statements
Posted: Fri May 29, 2009 5:14 pm
by onion2k
A combination of register_shutdown_function() to update a log file, and get_included_files() to build a list of which files were included should do the trick.
Re: Tracking include and require statements
Posted: Fri May 29, 2009 5:44 pm
by MmmVomit
Yeah, that looks like it could work. I could also use the auto_prepend_file directive to make it run on every page that gets loaded.
Since this will happen with every page load, I'll have to make sure this doesn't affect performance too much.
Re: Tracking include and require statements
Posted: Fri May 29, 2009 5:58 pm
by Weirdan
There's a dedicated extension for just what you need:
http://pecl.php.net/package/inclued
Re: Tracking include and require statements
Posted: Mon Jun 08, 2009 5:44 pm
by alex.barylski
Weirdan...dude your just on the ball today man...thats a pretty rockin extension
Ideally I am trying to figure out a way to determine every methods dependencies (in terms of functions, classes and/or includes.