想做一个php get_include_files()增强功能
I am interested in making an application that can automatically determine what files are included in php.
What I'm getting at is that I would like to make either a C/C++ or a C# application that runs in the background and as you're developing on your local machine, it can display included files by php as you launch pages running on your local apache.
What I thought about was to modify the function in php source code, but then I thought that would be a bad idea because then each new version of php, I'd have to go back and make the same modifications and I doubt everyone would do that.
So my question is, is it remotely possible to get all the included files that your php application used and then somehow display them to the user without using get_included_files() in your php program?
我有兴趣创建一个可以自动确定php中包含哪些文件的应用程序。 p>
我得到的是,我想制作一个在后台运行的C / C ++或C#应用程序,当你在本地机器上进行开发时,它 当你启动在你的本地apache上运行的页面时,可以通过php显示包含的文件。 p>
我想到的是修改php源代码中的函数,但后来我觉得这样会很糟糕 想法,因为然后每个新版本的PHP,我必须返回并做出相同的修改,我怀疑每个人都会这样做。 p>
所以我的问题是,是否可以远程实现 获取你的php应用程序使用的所有包含的文件,然后以某种方式将它们显示给用户,而不在php程序中使用get_included_files()? p> div>
You could go outside of PHP completely and rely on the underlying operating system to report these details. It would be difficult to match the request to the includes though so it would only work in a development situation.
If the OS is Linux/UNIX, you can run strace on the executable (assuming using Apache with mod_php, other situations more difficult).
If the OS is Windows, I'm not sure what to use but possible one of the SysInternals utilities (most are GUI but likely there is a console equivalent of strace or a version of strace for Windows).
Another option would be to use xdebug. It would show you much more information including profiling details, memory usage, etc. It is used as a PHP extension and it does make it easy to profile a whole request in one snapshot. Once you have a trace file, you can use WinCacheGrind (Windows), kCacheGrin (UNIX, maybe OS X too) and something else for OS X. I'd suggest trying this as it is the simplest approach and is quite powerful if you are looking to get this done rather than do exploratory programming.
If you are interested in doing exploratory programming, my suggested route would be to look at how xdebug works and see if you can write a hook to the functions you want to trace.