There’s some good info about common config options over here: Where Is php.ini, the PHP Configuration File?
The phpinfo()
function will tell you which php.ini file applies.
There’s some good info about common config options over here: Where Is php.ini, the PHP Configuration File?
The phpinfo()
function will tell you which php.ini file applies.
Putting these settings in /etc/php/7.2/apache/php.ini did the job:
[XDebug] xdebug.profiler_enable = 1 xdebug.profiler_output_dir = /tmp/xdebug xdebug.profiler_output_name = cachegrind.out.%p.%u.%H.%R.xt
The cachegrind files are now written to /tmp/xdebug.
So it just took me all night to figure out that in Xdebug ‘tracing’ is different to ‘profiling’.
It didn’t help that the xdebug.trace_output_name included an example format of ‘cachegrind.out.%s’. Why would you name a trace file cachegrind.out if only profile files are in cachegrind format!?
In my efforts to get profiling to work I found myself loading trace files into KCachegrind and getting the rather unhelpful message: “Could not open the file “/run/shm/xdebug/trace…xt”. Check it exists and you have enough permissions to read it.”
So the error message is about file permissions. I checked and checked and checked again but the file permissions were OK. The problem was I was loading a trace file, not a profile file.
So I gave up on KCachegrind and tried to get webgrind to work. Turns out loading a trace file (not a profile file) into webgrind doesn’t work either. I got the same problem reported by Sven about ‘parsers is undefined’. I fucked around trying to update the jquery.tablesorter plugin in webgrind, but the problem was due to the fact I was loading a tracing file, not a profiling file.
In the end I got it all figured out. Here’s my /etc/php5/mods-enabled/xdebug.ini file:
zend_extension=/usr/lib/php5/20131226/xdebug.so xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req ;xdebug.remote_host=127.0.0.1 xdebug.remote_host=10.1.1.203 ;xdebug.remote_port=9000 xdebug.remote_port=9999 ; http://www.xdebug.org/docs/all xdebug.profiler_enable=1 xdebug.profiler_output_dir=/run/shm/xdebug xdebug.profiler_output_name=cachegrind.out.%t.%R xdebug.auto_trace=1 xdebug.collect_assignments=1 xdebug.collect_includes=1 xdebug.collect_params=4 xdebug.collect_return=1 xdebug.collect_vars=0 xdebug.show_mem_delta=1 ;2 for HTML: xdebug.trace_format=0 xdebug.trace_options=1 xdebug.trace_output_dir=/run/shm/xdebug xdebug.trace_output_name=trace.%t.%R xdebug.var_display_max_children=-1 xdebug.var_display_max_data=-1 xdebug.var_display_max_depth=-1
The above config supports generation of tracing files and profiling files. I can now load my profiling files into KCachegrind and webgrind.
Everything is easy when you know how!
Today I enabled the allow_url_include configuration option in PHP on Apache on ProgClub MemberNet. This allows me to include a source file directly from svn, e.g.:
require_once( 'https://www.progclub.org/svn/pcrepo/slib/trunk/src/uri.php' );
Today I discovered the user_agent php.ini configuration option. Basically it allows you to specify the user agent PHP uses when it sends HTTP requests for files. I was screen scraping some data from Wikipedia (processing URI schemes) and it was replying with a 403 error, presumably because they’ve banned the default PHP user agent. Anyway I just changed my user agent to a copy of my one from Firefox and things started working. Pretty handy option!
I was working with phpMyAdmin and I got the following error:
File upload error - unable to create a temporary file in Unknown on line 0
The problem was that the upload_tmp_dir setting in my php.ini file was specified twice. Once up the top of the file where I was editing it, and then later in the file where I didn’t see it. So the setting I wanted wasn’t being applied. If you get this error double check you’ve only got one setting for upload_tmp_dir.