D
D
DeusModus2010-10-09 09:46:58
PHP
DeusModus, 2010-10-09 09:46:58

Are there ready-made solutions for building a dependency tree between files?

I would like to get (json, ini, associative array, xml - whatever) file inclusion tree (something like this ).

The problem can be solved in three ways:

  • 1. Overload standard designs
  • 2. some magic parameters in the debugger (xdebug is a cake, but it does not give complete information about the dependencies between files)
  • 3. grep and creating alternatives (like ov_include and catching the source via debug_backtrace)
  • 4. use willpower and eyes to go through all the files


The first option requires intervention in the interpreter and labor costs to update the patch for new versions of php.
The second one is unknown to me. Just in case, the Xdebug config: The third cool and probably the simplest, but in terms of performance harsh (we created a static list array inside the function, which checks if we are trying to loop or include an existing file, process backtrace, write results) when there are a lot of files . The fourth is not suitable for large projects. What for. Now I am recruiting juniors, and the documentation for the engine is only a third ready. I would like to print out the diagram of each page on the plotter so that the guys do not have to guess where and what.

zend_extension_ts="D:\PHP\ext\php_xdebug.dll"
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = "D:\server\profiling\"
xdebug.trace_output_name = %t.%s.%H
xdebug.collect_params 1
xdebug.collect_return 1
xdebug.collect_vars 1
xdebug.default_enable 1
xdebug.show_mem_delta 1
php_flag xdebug.auto_trace 1
xdebug.trace_format 1




Answer the question

In order to leave comments, you need to log in

4 answer(s)
J
justabaka, 2010-10-09
@DeusModus

Inclued + Graphwiz = Sorting out your PHP includes using Inclued

L
LastDragon, 2010-10-09
@LastDragon

> Xdebug would be a great option, but none of the utility that works with its output file contains the functionality of spying on inclusions
So I suggest to implement it yourself, especially since the format is very simple and it seems that all logic will be reduced to tracking "fn=require_once::. .." (cfn)
Example:

fl=ips_kernel/classDbMysql.php
fn=require_once::ips_kernel/classDbMysql.php
1 91512
cfn=php::define
calls=1 0 0
25 4
cfn=php::class_exists
calls=1 0 0
30 5
cfn=php::dirname
calls=1 0 0
32 1
cfn=require_once::ips_kernel/classDb.php
calls=1 0 0
32 36
cfn=php::extension_loaded
calls=1 0 0
1066 1
cfn=php::defined
calls=1 0 0
1066 5
cfn=php::dirname
calls=1 0 0
1068 1
cfn=require::ips_kernel/classDbMysqliClient.php
calls=1 0 0
1068 79

Connection:
ips_kernel/classDbMysql.php
    -> ips_kernel/classDb.php
    -> ips_kernel/classDbMysqliClient.php

BUT, the tree will be valid only for the current script (ie, it may depend on the input parameters), this can be solved by the script that will feed the xdebug file, and the output will be a tree for it.

L
LastDragon, 2010-10-09
@LastDragon

5) Use the xdebug output file - it has all the information and parsing it, in my opinion, is easier (http://kcachegrind.sourceforge.net/html/CallgrindFormat.html).

A
Alexey Sidorov, 2010-10-09
@Gortauer87

Is there no way to peep in the interpreter code what the include does? Perhaps there is already a solution

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question