blob: 2f222d830c986a97cd882ff7282e9b1f9eed5fce [file]
---
layout: post
status: PUBLISHED
published: true
title: "[PHP] Conditional breakpoints and new Twig features"
id: ad2c3a8f-b383-4f58-91c1-37cb4eb6bcb8
date: '2018-08-30 23:26:42 -0400'
categories: netbeans
tags:
- php
permalink: netbeans/entry/php-conditional-breakpoints-and-new
---
<p>
Hi all. Today, we will show you some new features which will be available in the <b>next NetBeans version</b>, maybe<br />
(NetBeans 10? NOTE: we cannot promise anything about release contents at the moment).</p>
<p>
First of all, if you would like to try new features, please build NetBeans yourself.</p>
<pre>
git clone git@github.com:apache/incubator-netbeans.git
cd incubator-netbeans
ant -Dcluster.config=full
(or ant -Dcluster.config=php)
</pre>
<p>
You can find the start-up files in the <i>nbbuild/netbeans/bin</i> directory if the build succeeds. So please run it.</p>
<h3>Debugger: Conditional breakpoints</h3>
<p>
You can stop the debugger if the context matches your condition.<br />
i.e. If the condition is true, the debugger stops on the breakpoint, otherwise, it does not stop there.</p>
<p>
I assume that you have already done the settings for debugging. (please see: <a href="http://wiki.netbeans.org/HowToConfigureXDebug">HowToConfigureXDebug</a>)<br />
If xdebug doesn't work, please ask someone via <a href="https://netbeans.apache.org/community/mailing-lists.html">Apache NetBeans mailing lists</a>. (Please don't ask here.)</p>
<p>
Just in my case(Ubuntu 18.04):</p>
<pre>
sudo apt install php-xdebug
sudo vim /etc/php/7.2/mods-available/xdebug.ini
# Change to the following
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.idekey="netbeans-xdebug"
</pre>
<p>
Let's try running with a sample code(index.php):</p>
<pre>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
$array = ["foo", "bar", "baz", "qux"];
foreach ($array as $value) {
echo $value;
}
?>
</body>
</html>
</pre>
<h4>Step 1: Enable a breakpoint</h4>
<p>You can enable it when you click a line number.</p>
<p><a href="https://blogs.apache.org/netbeans/mediaresource/25771e8e-3082-4920-925a-effbd57c99cb"><img src="https://blogs.apache.org/netbeans/mediaresource/25771e8e-3082-4920-925a-effbd57c99cb" alt="Nb-php-debugger-conditial-breakpoint-1.png"></img></a></p>
<h4>Step 2: Show the Breakpoint Properties dialog</h4>
<p>To show it, please right-click the breakpoint, then please click Breakpoint > Properties.</p>
<p><a href="https://blogs.apache.org/netbeans/mediaresource/8e448740-699e-4070-8f83-5941c005126c"><img src="https://blogs.apache.org/netbeans/mediaresource/8e448740-699e-4070-8f83-5941c005126c" alt="Nb-php-debugger-conditial-breakpoint-2.png"></img></a><br/><br/><br />
<a href="https://blogs.apache.org/netbeans/mediaresource/e66e4a2b-aedf-4a7f-aac4-8dada12e4764"><img src="https://blogs.apache.org/netbeans/mediaresource/e66e4a2b-aedf-4a7f-aac4-8dada12e4764" alt="Nb-php-debugger-conditial-breakpoint-3.png"></img></a></p>
<h4>Step 3: Input a condition</h4>
<p>Please check "Condition" and input your condition to the combo box, then click the OK button.</p>
<p><a href="https://blogs.apache.org/netbeans/mediaresource/83c2e5eb-da5d-4272-807f-5ba1dfe6398b"><img src="https://blogs.apache.org/netbeans/mediaresource/83c2e5eb-da5d-4272-807f-5ba1dfe6398b" alt="Nb-php-debugger-conditial-breakpoint-4.png"></img></a></p>
<h4>Step 4: Run Debug Project</h4>
<p>Please click Debug > Debug Project or the icon on the toolbar.</p>
<p>In this case, the debugger stops on the breakpont if $value is "baz".</p>
<p><a href="https://blogs.apache.org/netbeans/mediaresource/c1460e67-4caf-4a2c-909c-38c2be8d8bd2"><img src="https://blogs.apache.org/netbeans/mediaresource/c1460e67-4caf-4a2c-909c-38c2be8d8bd2" alt="Nb-php-debugger-conditional-breakpoints.gif"></img></a></p>
<h3>Twig: Code completion for delimiters, brackets, and quotes</h3>
<p>Twig editor supports code completion for delimeters( and ), brackets([, (, and {), and quotes(" and ').<br />
This feature is enabled by default. If you would like to disable, please uncheck the options (Tools > Options > Editor > Code Completion > Language: Twig File).</p>
<p><a href="https://blogs.apache.org/netbeans/mediaresource/385a0dd9-8988-4b06-ab56-7952d75ddb58"><img src="https://blogs.apache.org/netbeans/mediaresource/385a0dd9-8988-4b06-ab56-7952d75ddb58" alt="Nb-php-twig-autocomplete-options.png"></img></a><br />
<br/><br/><br />
<a href="https://blogs.apache.org/netbeans/mediaresource/6c4c7d0a-f17f-455f-8bb0-1953dbed4443"><img src="https://blogs.apache.org/netbeans/mediaresource/6c4c7d0a-f17f-455f-8bb0-1953dbed4443" alt="Nb-php-twig-autocomplete.gif"></img></a></p>
<h3>Twig: Palette support</h3>
<p>You can show the palette window. Please click Window > IDE Tools > Palette.</p>
<p><a href="https://blogs.apache.org/netbeans/mediaresource/c0758bcf-96b6-4ff0-8c9c-13d69fc44d97"><img src="https://blogs.apache.org/netbeans/mediaresource/c0758bcf-96b6-4ff0-8c9c-13d69fc44d97" alt="Nb-php-twig-palette.png"></img></a></p>
<p>
That's all for today. As always, please test it.<br />
If you find some issues or enhancements, please report them to <a href="https://issues.apache.org/jira/projects/NETBEANS/issues">JIRA</a><br />
<i>(Components: php - Debugger, php - Twig)</i>. Thanks.</p>