blob: 3b7eccb377517456a57668db3b947bfaf7d98668 [file]
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
= [PHP] Conditional breakpoints and new Twig features
:author: Junichi
:revdate: 2018-08-30
:jbake-type: post
:jbake-tags: blogentry
:jbake-status: published
:keywords: Apache NetBeans blog index
:description: Apache NetBeans blog index
:toc: left
:toc-title:
:syntax: true
:experimental:
Hi all. Today, we will show you some new features which will be available in the *next NetBeans version*, maybe
(NetBeans 10? NOTE: we cannot promise anything about release contents at the moment).
First of all, if you would like to try new features, please build NetBeans yourself.
[source,console]
----
git clone git@github.com:apache/incubator-netbeans.git
cd incubator-netbeans
ant -Dcluster.config=full
(or ant -Dcluster.config=php)
----
You can find the start-up files in the nbbuild/netbeans/bin directory if the build succeeds. So please run it.
== Debugger: Conditional breakpoints
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.
I assume that you have already done the settings for debugging. (please see: xref:../../wiki/HowToConfigureXDebug.adoc[HowToConfigureXDebug])
If xdebug doesn't work, please ask someone via xref:../../community/mailing-lists.adoc[Apache NetBeans mailing lists]. (Please don't ask here.)
Just in my case(Ubuntu 18.04):
[source,console]
----
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"
----
Let's try running with a sample code(index.php):
[source,php]
----
<!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>
----
=== Step 1: Enable a breakpoint
You can enable it when you click a line number.
image::blogs/entry/php-conditional-breakpoints-and-new1.png[]
=== Step 2: Show the Breakpoint Properties dialog
To show it, please right-click the breakpoint, then please click menu:Breakpoint[Properties].
image::blogs/entry/php-conditional-breakpoints-and-new2.png[]
image::blogs/entry/php-conditional-breakpoints-and-new3.png[]
=== Step 3: Input a condition
Please check "Condition" and input your condition to the combo box, then click the OK button.
image::blogs/entry/php-conditional-breakpoints-and-new4.png[]
=== Step 4: Run Debug Project
Please click Debug > Debug Project or the icon on the toolbar.
In this case, the debugger stops on the breakpont if $value is "baz".
image::blogs/entry/php-conditional-breakpoints-and-new5.gif[]
== Twig: Code completion for delimiters, brackets, and quotes
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 (menu:Tools[Options > Editor > Code Completion > Language: Twig File]).
image::blogs/entry/php-conditional-breakpoints-and-new6.png[]
image::blogs/entry/php-conditional-breakpoints-and-new7.gif[]
== Twig: Palette support
You can show the palette window. Please click menu:Window[IDE Tools > Palette].
image::blogs/entry/php-conditional-breakpoints-and-new8.png[]
That's all for today. As always, please test it.
If you find some issues or enhancements, please report them to JIRA
(Components: php - Debugger, php - Twig). Thanks.