XDebug can track changes in variables, just enable xdebug.collect_assignments and xdebug.collect_params , so when you create a trace log file, you should see the changes.
Configuration Example:
xdebug.default_enable = 1 ; bool: The stacktraces will be shown by default on an error event. xdebug.collect_vars = 1 ; bool: Gather information about which variables are used in a certain scope. xdebug.show_local_vars=1 ; int: Generate stack dumps in error situations. xdebug.collect_assignments=1 ; bool: Controls whether Xdebug should add variable assignments to function traces. xdebug.collect_params=4 ; int1-4: Collect the parameters passed to functions when a function call is recorded. xdebug.collect_return=1 ; bool: Write the return value of function calls to the trace files. xdebug.var_display_max_children=256 ; int: Amount of array children and object properties are shown. xdebug.var_display_max_data=1024 ; int: Max string length that is shown when variables are displayed. xdebug.var_display_max_depth=5 ; int: How many nested levels of array/object elements are displayed. xdebug.trace_output_dir="/var/log/xdebug" ; string: Directory where the tracing files will be written to.
Then, before or after assigning the variable for the first time, start tracking the code by adding this to your PHP code:
xdebug_start_trace();
then add xdebug_stop_trace(); to the end, where do you think this has already happened.
Then check the file generated in the configured directory (specified by xdebug.trace_output_dir ). If the file is large, filter it by a specific variable using grep , for example.
grep --color=auto variable trace-log.xt
or filter it in a smaller file: grep pattern trace-log.xt > smaller.log.txt .
Another alternative would be to use phpdbg .
source share