Skip to content
Advertisement

How can I find a list of all the php files that are called when a page loads?

I’m taking over a website for my job. The last developer didn’t understand the architecture of our CMS and hacked his way around everything. Also, he documented nothing.

I need to track back and see what files are being called when a website is called? What’s the easiest way to do this?

I know I can do:

ps aux | grep php

That only shows me the currently running scripts though. If I don’t run the command at the right time I’ll miss stuff.

How can I view a log of every file that’s run when a URL is called? This is a basic LAMP stack.

Thank you!

Advertisement

Answer

Solution from within PHP:

http://php.net/manual/en/function.get-included-files.php

use get_included_files() to get an array of all that have been included using include, include_once, require or require_once.

You could then do this:

register_shutdown_function( function(){
  echo implode( PHP_EOL, get_included_files() );
} );

At which point you could write the list to disk with each execution.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement