| --- |
| layout: post |
| title: "[PHP] Conditional breakpoints and new Twig features" |
| date: '2018-08-30T00:00:00+00:00' |
| categories: netbeans |
| --- |
| <p>
|
| Hi all. Today, we will show you some new features which will be available in the <b>next NetBeans version</b>, maybe
|
| (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.
|
| 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>)
|
| 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>
|
| <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>
|
|
|
| <h4>Step 2: Show the Breakpoint Properties dialog</h4>
|
| <p>To show it, please right-click the breakpoint, then please click Breakpoint > Properties.</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/>
|
| <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>
|
|
|
| <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>
|
| <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>
|
|
|
| <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>
|
|
|
| <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>
|
|
|
| <h3>Twig: Code completion for delimiters, brackets, and quotes</h3>
|
| <p>Twig editor supports code completion for delimeters( and ), brackets([, (, and {), and quotes(" and ').
|
| 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>
|
| <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/>
|
| <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>
|
|
|
| <h3>Twig: Palette support</h3>
|
| <p>You can show the palette window. Please click Window > IDE Tools > Palette.</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>
|
| That's all for today. As always, please test it.
|
| If you find some issues or enhancements, please report them to <a href="https://issues.apache.org/jira/projects/NETBEANS/issues">JIRA</a>
|
| <i>(Components: php - Debugger, php - Twig)</i>. Thanks.
|
| </p> |