1

I have a standard web app written in PHP. I am using nginx with php-fpm.

Lets say public/index.php is my entry point and during a single request 25 files are being autoloaded.

Can I get a list of these files using some lsof or other command (I do want to use some unix command, not PHP code)?

Background: I have some messy legacy app and there is no obvious way to find file (controller) that is used on particular page. Just for fun I wondered if I can run some lsof-ish command, reload the page and get what file has been accessed from /my/project/some/nested/directory/containing/controllers.

Kamil Latosinski
  • 756
  • 5
  • 28

1 Answers1

0

it depends how your autoload works - but these function should do it

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

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

$included_files = get_included_files();

foreach ($included_files as $filename) {
    echo "$filename\n";
}
Kapsonfire
  • 1,013
  • 5
  • 17
  • I should have mentioned I would like to use some unix command. Sorry for that, but thanks for reply. – Kamil Latosinski Jul 11 '18 at 11:28
  • i dont think its possible because every will is opened by the php command... unix does not know which file has been opened by a specific php command... try to debug/backtrace directly in php with above code – Kapsonfire Jul 11 '18 at 11:33