Update: I’ve recently (as of February 2015) created a ‘Netbeans Module’ that you can import into Netbeans to automatically set the correct settings (instead of having to manually following this guide, see: https://github.com/allebb/netbeans-psr-formatting
Recently I’ve been looking into the PHP-FIG PSR standards and in an attempt to standardise my coding styles to a widely used standard, the PSR standards look like a great place to start.
My IDE of choice is NetBeans, its a great IDE, supports a whole load of languages, has an awesome plugin system and has never let me down since I’ve been using it! It has some really great features of which I love such as integrated Git support, deployment to remote development servers, bug tracker integration etc… and one of my favourites, the automatic code syntax formatting.
Up until recently the automatic code formatting feature in NetBeans (CTRL+SHIFT+F) has been great for my needs but since trying to adopt the PSR-1/0, NetBeans is annoying auto-formatting braces on the same line however to correctly adhere to the guidelines they need to be on new lines.
So I spent a few days trying to find some information a plugin online for NetBeans to do this and after a few days of searching I managed to find some awesome (maybe obvious!) information so I thought I’d share with others how I did this and how you can change a whole load of other formatting/syntax
So to do this, in NetBeans open up the Preferences, then click on Editor > Formatting > Then change the Language drop-down to PHP > Change the category to Braces and then change the Class declaration and Method declaration settings to New Line.
Click the image above to view it full-size!
There are a whole load of other coding format settings in this panel, feel free to have a play around, you can do pretty much everything! – Most of the default settings in NetBeans already adhere to the PSR-1/PSR-2 standards I’m pretty sure I only had to change these brace settings to set them over new lines.
Hope this was helpful 🙂
4 replies on “Configuring NetBeans for PSR-1 and PSR-2 coding guidelines.”
[…] Configuring NetBeans for PSR-1 and PSR-2 coding guidelines. | Life in apps, os’s and code! […]
[…] Bobby Allens Netbeans Article […]
[…] Configuring NetBeans for PSR-1 and PSR-2 coding guidelines. […]
[…] 3。让NetBeans 支持PHP的 PSR-1和PSR-2 编码标准。参考：Configuring NetBeans for PSR-1 and PSR-2 coding guidelines.插件下载：netbeans-psr-formatting […]