PHP: Colors in var_dump (Ubuntu)

萝らか妹 提交于 2019-12-03 03:13:39

You're looking for XDebug.

sudo apt-get install php5-xdebug
sudo /etc/init.d/apache2 restart

and you're done.

Note: Maerlyn's approach should be taken for its simplicity. I wasn't aware of php5-xdebug being in the repos. I've decided to leave this answer because I feel it adds some value to future readers.


    sudo apt-get install php5-dev php-pear

Install Xdebug

    sudo pecl install xdebug

You should see something like: Installing '/usr/lib/php5/20090626+lfs/xdebug.so' when it finishes installing. Make note of the 20090626+lfs portion.

Edit the php.ini

    gksudo gedit /etc/php5/apache2/php.ini

Add this to it:

    zend_extension="/usr/lib/php5/20090626+lfs/xdebug.so"

Restart apache

    sudo /etc/init.d/apache2 restart

Now when you do a var_dump it should be formatted, this is assuming html_errors is On.

There's a php tool to do even more than xdebug's var_dump and it's a simple PHP class, so can be used on any environmment:

http://kint-php.github.io/kint/

you could use a javascript library to do the syntax highlighting. something like: http://alexgorbatchev.com/SyntaxHighlighter/ but there are many other options as well.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!