PHP Code Profiling

Profiling FreePBX is the process of finding where slowdowns in the code are. This walkthrough will guide you into installing a profiler for PHP locally on your system

 

CentOS 7.x

Install and setup PHP components

yum install -y php56w-pear php56w-devel php56w-mcrypt pecl install xhprof-beta echo "extension=xhprof.so" > /etc/php.d/xhprof.ini pecl uninstall mongodb pecl install mongodb-1.4.4 echo "extension=mongodb.so" > /etc/php.d/mongodb.ini service httpd restart

Now Install the GUI into a web directory

cd /var/www/html/ wget https://github.com/perftools/xhgui/archive/0.9.0.tar.gz tar vxzf 0.9.0.tar.gz cd xhgui-0.9.0 php install.php cp config/config.default.php config/config.php

Edit /var/www/html/xhgui-0.9.0/config/config.php, make sure this function returns true

return array(     'profiler.enable' => function() {         return true;     } );

Adding the following snippet of code to xhgui/external/header.php right before ignore_user_abort(true); call

Add line to top of /etc/freepbx.conf

Browse to <webhost>/xhgui-0.9.0/webroot

CentOS 6.x

Install and setup PHP components

Now Install the GUI into a web directory

Edit /var/www/html/xhgui-0.5.2/config/config.php, make sure this function returns true

To use in CLI commands simply do this:

At this point you will be able to view the profiling stats in the gui. Note: this address structure is VERY INSECURE. 

For web commands applications you need include:

For help setting up mongodb 2.6 on CentOS 6 see the following:

https://www.programering.com/a/MjNxYjMwATU.html

Return to Documentation Home I Return to Sangoma Support