Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
As we start testing our code, it would be helpful to know which code is tested and which is not. Code coverage can give us a starting point for seeing which section of the code still requires testing.
phpunit.xml Configuration
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">classes</directory>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="tests/log/report" lowUpperBound="35"
highLowerBound="70"/>
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false"/>
<log type="testdox-html" target="tests/log/testdox.html"/>
<log type="testdox-text" target="tests/log/testdox.txt"/>
</logging>
Installing Xdebug
Xdebug is an extension for PHP to assist with debugging and development. It contains a single step debugger to use with IDEs; it upgrades PHP's var_dump() function; it adds stack traces for Notices, Warnings, Errors and Exceptions; it features functionality for recording every function call and variable assignment to disk; it contains a profiler; and it provides code coverage functionality for use with PHPUnit.
Enable Xdebug in MAMP for Mac
After installing Xdebug, follow the steps below to enable Xdebug in MAMP, non-pro version. MAMP Pro allows for a simple check box in preferences under PHP.
Step 1: Determine PHP Version
In MAMP, press Open start page View phpinfo to get PHP version Note which PHP version you have
Step 2: Configure php.ini
MAMP has two configuration files for each PHP version:
- /Applications/MAMP/conf/php[version]/php.ini
- /Applications/MAMP/bin/php/php[version]/conf/php.ini
- Locate the xdebug section at the bottom of both of these files
- Uncomment zend_extension line in both files (remove the ;)
- Add the following lines to the xdebug section in both files:
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1 # Not safe for production servers
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true
Result should look something like:
[xdebug]
zend_extension="/Applications/MAMP/bin/php/php7.0.8/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so"
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1 # Not safe for production servers
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true
Step 3: Restart MAMP!
Restart MAMP and Xdebug should be all set for whatever environment you use!
Visit the page you desire to debug with ?XDEBUG_SESSION_START=xdebug appended to the URL.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up