NetBeans71andPhpStorm3

(Difference between revisions)
(Go To Class)
 
(5 intermediate revisions not shown)
Line 1: Line 1:
Author: Lada Riha (vriha@netbeans.org)
Author: Lada Riha (vriha@netbeans.org)
-
Following text is supposed to point out features of PhpStorm that could be useful in NetBeans. Its purpose is not to find “best PHP IDE” but to suggest what could be implemented in NetBeans in future. Just because this text contains functionality implemented by PhpStorm and not by NetBeans it doesn’t mean that NetBeans are worst. I simply did not include information about what is better in NetBeans (and yes, there is a lot of thing :)
+
Following text is supposed to point out features of PhpStorm that could be useful in NetBeans. Its purpose is not to find “best PHP IDE” but to suggest what could be implemented in NetBeans in future. Just because this text contains functionality implemented by PhpStorm and not by NetBeans it doesn’t mean that NetBeans is worse. I simply did not include information about what is better in NetBeans (and yes, there is a lot of thing :)
I did not include everything I've found, but only the in my opinion most interesting and useful functionality. The most important and most wanted in NetBeans would be probably features mentioned in section Refactoring. Ability to inspect code for potential problems, rename php class file together with class renaming or find duplicates are really useful and help user to better/easier reorganize code.
I did not include everything I've found, but only the in my opinion most interesting and useful functionality. The most important and most wanted in NetBeans would be probably features mentioned in section Refactoring. Ability to inspect code for potential problems, rename php class file together with class renaming or find duplicates are really useful and help user to better/easier reorganize code.
 +
 +
See similar [[NetBeans71andEclipsePDT32|NetBeans 7.1 vs Eclipse for PHP Developers 3.0.2]]
== Editor ==
== Editor ==
-
=== Customizing code styles and font styles and colors ===
+
=== Expand and optimize CSS property ===
-
PhpStorm and NetBeans both offer a lot of options to customize code styles. One has more detailed settings of that, the other one of something else so it’s hard to tell which is better. However PhpStorm offers also settings for PhpDoc which is missing in NetBeans. Also PhpStorm let user to define some settings for other web related languages (HTML, CSS, JS...).
+
Imagine you have following code in css file:
-
Configuration of font styles and colors is way better in NetBeans. For example in PhpStorm you can’t change color setting without creating new custom color scheme. Also font settings are more detailed in NetBeans.
+
<pre>
 +
    border-top-right-radius: 4em;
 +
    border-top-left-radius: 4em;
 +
    border-bottom-right-radius: 4em;
 +
    border-bottom-left-radius: 2em;
 +
</pre>
-
=== Go To Class ===
+
In that case PhpStorm shows annotation hint that allows you to shrink it to just one line:
 +
<pre>
 +
    border-radius: 4em 4em 4em 2em;
 +
</pre>
-
There is an option to navigate to PHP Class which is missing in NetBeans. When you have one class per file (with the same name) you can use Go To File in NetBeans but when you have more classes in one file, Go To File doesn’t help you.
+
Now it shows another annotation that lets you expand the code to the original 4 line form.
-
'''TMYSIK''' NetBeans has Go To Type (CTRL + o) as well - or am I missing something?
+
=== Customizing code styles and font styles and colors ===
 +
 
 +
* Enhancement bug: [http://netbeans.org/bugzilla/show_bug.cgi?id=206971]
 +
* Enhancement bug (already created): [http://netbeans.org/bugzilla/show_bug.cgi?id=174441] and [http://netbeans.org/bugzilla/show_bug.cgi?id=190545]
 +
 
 +
PhpStorm and NetBeans both offer a lot of options to customize code styles. One has more detailed settings of that, the other one of something else so it’s hard to tell which is better. However PhpStorm offers also settings for PhpDoc which is missing in NetBeans. Also PhpStorm let user to define some settings for other web related languages (HTML, CSS, JS...).
 +
 
 +
Configuration of font styles and colors is way better in NetBeans. For example in PhpStorm you can’t change color setting without creating new custom color scheme. Also font settings are more detailed in NetBeans.
=== Code completion in Find dialog ===
=== Code completion in Find dialog ===
 +
 +
* Enhancement bug: [http://netbeans.org/bugzilla/show_bug.cgi?id=206979]
[[File:NBPHPS_Findcc.png]]
[[File:NBPHPS_Findcc.png]]
Line 26: Line 45:
=== Show applied styles for tag ===
=== Show applied styles for tag ===
 +
 +
* Enhancement bug: [http://netbeans.org/bugzilla/show_bug.cgi?id=206972]
[[File:NBPHPS_AppliedStyles.png]]
[[File:NBPHPS_AppliedStyles.png]]
Line 32: Line 53:
=== Autocorrection of PhpDoc ===
=== Autocorrection of PhpDoc ===
 +
 +
* Enhancement bug: [http://netbeans.org/bugzilla/show_bug.cgi?id=206969]
[[File:NBPHPS_Phpdoc.png]]
[[File:NBPHPS_Phpdoc.png]]
Line 38: Line 61:
=== Formatting of unused variable ===
=== Formatting of unused variable ===
 +
 +
* Enhancement bug: [http://netbeans.org/bugzilla/show_bug.cgi?id=206970]
[[File:NBPHPS_Unused.png]]
[[File:NBPHPS_Unused.png]]
Line 45: Line 70:
Also there is a nice feature that tracks unused values of variables. Look at the picture below you can see that $foo is overwritten immediately and PhpStorm shows it as unused variable (value) and shows hints with explanation.
Also there is a nice feature that tracks unused values of variables. Look at the picture below you can see that $foo is overwritten immediately and PhpStorm shows it as unused variable (value) and shows hints with explanation.
 +
== JavaScript ==
 +
 +
=== JavaScript debugger ===
 +
 +
Built-in debugger for client-side javascript.
 +
 +
=== Extract method ===
 +
 +
Similar to Extract method feature described below for PHP. You can select code block and convert it to method and its call.
 +
 +
=== Node.JS plugin ===
 +
 +
Node.JS is a JavaScript framework/platform for server-side JavaScript (see [http://nodejs.org/ nodejs.org]. This plugin offers code completion, debugging, running application etc (there is a workaround for running nodejs applications in NetBeans by setting a PHP project to run as a Script and set PHP Interpreter to Node script.
== File management ==
== File management ==
=== Name of copied file ===
=== Name of copied file ===
 +
 +
* Enhancement bug: [http://netbeans.org/bugzilla/show_bug.cgi?id=206975]
If you copy some file in PhpStorm and press Ctrl+V to paste it, you are asked to specify new name. I think this is more useful than NetBeans way when the new file is automatically renamed to “name_1”. On the other hand, in the rename dialog in PhpStorm there is by default name of the original file, so you have to manually change it. I guess ideal way is to combine these approaches, after pasting file user could be asked to specify new name but the “name_1” will be prefilled so he could simple confirm it.
If you copy some file in PhpStorm and press Ctrl+V to paste it, you are asked to specify new name. I think this is more useful than NetBeans way when the new file is automatically renamed to “name_1”. On the other hand, in the rename dialog in PhpStorm there is by default name of the original file, so you have to manually change it. I guess ideal way is to combine these approaches, after pasting file user could be asked to specify new name but the “name_1” will be prefilled so he could simple confirm it.
Line 55: Line 95:
=== Inspect code ===
=== Inspect code ===
 +
 +
* Enhancement bug: [http://netbeans.org/bugzilla/show_bug.cgi?id=206974]
[[File:NBPHPS_Inspect.png]]
[[File:NBPHPS_Inspect.png]]
Line 61: Line 103:
=== Extract Method ===
=== Extract Method ===
 +
 +
* Enhancement bug (already created): [http://netbeans.org/bugzilla/show_bug.cgi?id=183807]
Extract Method action allows to replace selected piece of code with method call. If you select some code and invoke this action, new method will be defined (you can select properties such as parameters, visibility and name) and instead of the selected code there will be single line method call (and of course this method will contain the selected code).
Extract Method action allows to replace selected piece of code with method call. If you select some code and invoke this action, new method will be defined (you can select properties such as parameters, visibility and name) and instead of the selected code there will be single line method call (and of course this method will contain the selected code).
Line 67: Line 111:
=== Refactor Rename ===
=== Refactor Rename ===
 +
 +
* Enhancement bug (already created): [http://netbeans.org/bugzilla/show_bug.cgi?id=189820]
Both IDE support refactor rename on php classes. I can’t figure out how to force PhpStorm to rename also occurrences of the class name in other files. This handles NetBeans way better. However PhpStorm has a nice feature to rename containing file. So if your php file contains only this one class, you can rename the file itself during the rename refactor action. This is useful if you are using autoloaders that relies on file name.
Both IDE support refactor rename on php classes. I can’t figure out how to force PhpStorm to rename also occurrences of the class name in other files. This handles NetBeans way better. However PhpStorm has a nice feature to rename containing file. So if your php file contains only this one class, you can rename the file itself during the rename refactor action. This is useful if you are using autoloaders that relies on file name.
=== Duplicates ===
=== Duplicates ===
 +
 +
* Enhancement bug: [http://netbeans.org/bugzilla/show_bug.cgi?id=206973]
[[File:NBPHPS_Dupl.png]]
[[File:NBPHPS_Dupl.png]]
Line 86: Line 134:
=== Compare with clipboard ===
=== Compare with clipboard ===
 +
 +
* Enhancement bug: [http://netbeans.org/bugzilla/show_bug.cgi?id=206976]
[[File:NBPHPS_Clipboard.png]]
[[File:NBPHPS_Clipboard.png]]
Line 93: Line 143:
=== Local history for directories ===
=== Local history for directories ===
 +
 +
* Enhancement bug: [http://netbeans.org/bugzilla/show_bug.cgi?id=206977]
This basically only lists all changes in all files in directory, but it’s faster way to track changes in directory than checking every single file.
This basically only lists all changes in all files in directory, but it’s faster way to track changes in directory than checking every single file.
Line 103: Line 155:
=== Show Structure ===
=== Show Structure ===
 +
 +
* Enhancement bug: [http://netbeans.org/bugzilla/show_bug.cgi?id=206978]
[[File:NBPHPS_Structure.png]]
[[File:NBPHPS_Structure.png]]
-
PhpStorm equivalent of NetBeans’ Navigater offers more filter options (show contants, show fields, includes, show inherited etc.) while in NetBeans there are only 3 options to use and some of this functionality is in Php Type Hierarchy. In PhpStorm it also tries to deduct type of variable.
+
PhpStorm equivalent of NetBeans’ Navigator offers more filter options (show contants, show fields, includes, show inherited etc.) while in NetBeans there are only 3 options to use and some of this functionality is in Php Type Hierarchy. In PhpStorm it also tries to deduct type of variable.
=== Open URL ===
=== Open URL ===
   
   
This is probably not going to be used a lot but sometimes it can be useful. PhpStorm can open file from given URL.
This is probably not going to be used a lot but sometimes it can be useful. PhpStorm can open file from given URL.

Current revision as of 12:05, 13 January 2012

Author: Lada Riha (vriha@netbeans.org)

Following text is supposed to point out features of PhpStorm that could be useful in NetBeans. Its purpose is not to find “best PHP IDE” but to suggest what could be implemented in NetBeans in future. Just because this text contains functionality implemented by PhpStorm and not by NetBeans it doesn’t mean that NetBeans is worse. I simply did not include information about what is better in NetBeans (and yes, there is a lot of thing :)

I did not include everything I've found, but only the in my opinion most interesting and useful functionality. The most important and most wanted in NetBeans would be probably features mentioned in section Refactoring. Ability to inspect code for potential problems, rename php class file together with class renaming or find duplicates are really useful and help user to better/easier reorganize code.

See similar NetBeans 7.1 vs Eclipse for PHP Developers 3.0.2

Contents

Editor

Expand and optimize CSS property

Imagine you have following code in css file:

    border-top-right-radius: 4em;
    border-top-left-radius: 4em;
    border-bottom-right-radius: 4em;
    border-bottom-left-radius: 2em;

In that case PhpStorm shows annotation hint that allows you to shrink it to just one line:

    border-radius: 4em 4em 4em 2em;

Now it shows another annotation that lets you expand the code to the original 4 line form.

Customizing code styles and font styles and colors

  • Enhancement bug: [1]
  • Enhancement bug (already created): [2] and [3]

PhpStorm and NetBeans both offer a lot of options to customize code styles. One has more detailed settings of that, the other one of something else so it’s hard to tell which is better. However PhpStorm offers also settings for PhpDoc which is missing in NetBeans. Also PhpStorm let user to define some settings for other web related languages (HTML, CSS, JS...).

Configuration of font styles and colors is way better in NetBeans. For example in PhpStorm you can’t change color setting without creating new custom color scheme. Also font settings are more detailed in NetBeans.

Code completion in Find dialog

  • Enhancement bug: [4]

File:NBPHPS_Findcc.png

PhpStorm offers code completion in Find dialog. It works in all file formats and makes finding a bit more faster.

Show applied styles for tag

  • Enhancement bug: [5]

File:NBPHPS_AppliedStyles.png

Right click on some HTML tag and press ‘Show applied styles for tag’. Window with all applied css properties will be shown. It also works in Smarty tpl file in which relative addresses for css styles (used in “<link rel=”stylesheet”...”) are not the same as they are in generated php file. This feature is in some way similiar to CSS Preview in NetBeans but instead of showing the styled element, it lists all its style properties.

Autocorrection of PhpDoc

  • Enhancement bug: [6]

File:NBPHPS_Phpdoc.png

If you change method declaration so the PhpDoc doesn’t correspond anymore, it is underlined and a hint shows explanation. If you click on the bulb icon, you can automatically update PhpDoc.

Formatting of unused variable

  • Enhancement bug: [7]

File:NBPHPS_Unused.png

All unused variables are gray by default in PhpStorm. Personally, I like it more then underscoring in NetBeans.

Also there is a nice feature that tracks unused values of variables. Look at the picture below you can see that $foo is overwritten immediately and PhpStorm shows it as unused variable (value) and shows hints with explanation.

JavaScript

JavaScript debugger

Built-in debugger for client-side javascript.

Extract method

Similar to Extract method feature described below for PHP. You can select code block and convert it to method and its call.

Node.JS plugin

Node.JS is a JavaScript framework/platform for server-side JavaScript (see nodejs.org. This plugin offers code completion, debugging, running application etc (there is a workaround for running nodejs applications in NetBeans by setting a PHP project to run as a Script and set PHP Interpreter to Node script.

File management

Name of copied file

  • Enhancement bug: [8]

If you copy some file in PhpStorm and press Ctrl+V to paste it, you are asked to specify new name. I think this is more useful than NetBeans way when the new file is automatically renamed to “name_1”. On the other hand, in the rename dialog in PhpStorm there is by default name of the original file, so you have to manually change it. I guess ideal way is to combine these approaches, after pasting file user could be asked to specify new name but the “name_1” will be prefilled so he could simple confirm it.

Refactoring

Inspect code

  • Enhancement bug: [9]

File:NBPHPS_Inspect.png

I’ve found this feature quite useful. It inspects code (php, html, js, css...) in selected files/project and looks for potential errors like empty tags, usage of deprecated methods, incorrect php doc, spelling problems and so on. For some errors it offers quick fixes or excluding them from result. Problems can be grouped by severity, directory etc. You can also export results to html or xml file. Of course there is option to select what should be find with which severity so you can adjust inspections in global scope or per project.

Extract Method

  • Enhancement bug (already created): [10]

Extract Method action allows to replace selected piece of code with method call. If you select some code and invoke this action, new method will be defined (you can select properties such as parameters, visibility and name) and instead of the selected code there will be single line method call (and of course this method will contain the selected code).

There are also actions like Introduce variable (see blog here) but I don’t think they can really save some time.

Refactor Rename

  • Enhancement bug (already created): [11]

Both IDE support refactor rename on php classes. I can’t figure out how to force PhpStorm to rename also occurrences of the class name in other files. This handles NetBeans way better. However PhpStorm has a nice feature to rename containing file. So if your php file contains only this one class, you can rename the file itself during the rename refactor action. This is useful if you are using autoloaders that relies on file name.

Duplicates

  • Enhancement bug: [12]

File:NBPHPS_Dupl.png

PhpStorm allows to find duplicate parts of code. You can specify which language (file format) should be inspected (PHP, HTML, JavaScript...). For each format there are some options to narrow down the inspections (for example for PHP you can specify minimum number of lines of code that could be marked as duplicate). There is also option to inspect only specified files or the whole project.


Other

Show recent changes

File:NBPHPS_Recent.png

Using keyboard shortcut Shift+Alt+C you can easily review all recent changes you’ve made. You can also select some listed file and review changes the same way as if you use versioning system. It’s not a killer feature but it can help you to get in the picture if you haven’t seen your project for some time.

Compare with clipboard

  • Enhancement bug: [13]

File:NBPHPS_Clipboard.png

This feature allow you to compare selected code with content of your clipboard. The result is displayed in the same way as if you use some versioning system and sometimes it may be pretty handy (not only for php code but in general for all languages).


Local history for directories

  • Enhancement bug: [14]

This basically only lists all changes in all files in directory, but it’s faster way to track changes in directory than checking every single file.

Diagrams

File:NBPHPS_Uml.png

PhpStorm can generate sort of UML diagrams from given classes so it is easier to understand architecture of your project. You can show class’ methods and variables and do some basic refactoring from the diagram (i.e. renaming). Diagrams can be exported to various formats (png, jpg...) or printed. This is also useful for making documentation.

Show Structure

  • Enhancement bug: [15]

File:NBPHPS_Structure.png

PhpStorm equivalent of NetBeans’ Navigator offers more filter options (show contants, show fields, includes, show inherited etc.) while in NetBeans there are only 3 options to use and some of this functionality is in Php Type Hierarchy. In PhpStorm it also tries to deduct type of variable.

Open URL

This is probably not going to be used a lot but sometimes it can be useful. PhpStorm can open file from given URL.

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo