WordPress development with PHPStorm

For years, I used the NetBeans for all my WordPress related development, but due to the various issues, I gave up on NetBeans earlier this year. Since March I have been using PHPStorm, and after a few months, I can say that PHPStorm will remain my main IDE for PHP/WordPress development for the foreseeable future.

PHPStorm is developed by the JetBrains and it is one among many different IDE’s and development tools they make for various programming languages and work on all major platforms (Windows, Linux and macOS).

PHPStorm IDE with open project

Working with projects

One of the basic features that IDE needs to be done well is the handling of projects. PHPStorm can be opened in multiple instances, each one running different project. For the most part, projects don’t share settings, and you can set up each project differently, and that includes the build process for SCSS or JavaScript, the layout of the environment, version control and everything else.

For me, this was a bit confusing at first, because, right now I have 10 projects created with PHPStorm, covering different types of websites made for the development of various plugins, and sharing settings would make sense for many of the projects. But, most settings can be exported and imported back to make things easier, and some settings can be global (that too can be confusing, especially since some global settings were not working for me in some cases).

For my particular development setups (some websites are working under XAMPP, some under Local by Flywheel), PHPStorm has been handling projects exceptionally well so far, and with recent 2019.2 update, that has been improved a lot with better WordPress support.

It has full Git (and other versioning systems) support, and you can do anything Git related directly from the plugin interface. I still use TortoiseGit, but PHPStorm has been really great with the Git support right in the IDE.

WordPress Support

WordPress development can be tricky, considering that a lot of things depend on the filters and actions, and PHPStorm handles that very well (for the most part). Setting the project as WordPress project will ensure that PHPStorm caches WordPress functions and classes, it can even adjust coding code style and other things too.

Support for actions and filters are very good, but some things are not obvious when you start using it. When you start typing add_action or add_filter, PHPStorm will provide autocomplete for the action/filter names. And, the line with add_action or add_filter will include invocation location arrow to quickly bring you to the place that hook is run. Resolving callbacks work fine for methods and functions.

Search for the action inside the selected directory

There are no Find Usages for filter/actions, and instead, you need to use Find dialogue. That is the only issue I have with that, and it is a minor issue, to begin with, everything else WordPress related has been great.

CSS/JS Build process

PHPStorm has own File Watcher system that can monitor changes in any file and perform actions based on the File Watcher rules. These can be simple rules, and they can be quite complicated based on the regular expressions to get the files.

File watcher transforming SCSS to CSS

File Watchers can be a pain to configure at first, but, the PHPStorm documentation and support were very helpful, and it works great now.

And, since I am not a big fan of having full Node.js build system that has complex build files and things like that, I really like the way PHPStorm handles that. It is all defined on the project level settings, and you don’t need any extra files inside your project for transforming SCSS to CSS, run minification or something else. You still need Node.js installed, but I really hate managing packages and all other nonsense Node brings, PHPStorm conveniently hides all that, and does things in the background with a much easier way to configure things.

Linting and hinting can be done using files, and PHPStorm detects those, and it can also have all these rules set in the project settings, and avoid having these extra files in projects too.

How much resources does it use?

PHPStorm creates cache files for each project and these files can take a lot of space (currently over 5GB of cache used for my projects), compared to NetBeans, it is a huge increase. But, because of such a large cache and the way it works with it, a lot of operations are almost instantaneous. I am yet to notice issues with scanning large projects, managing duplicated code and things like that. This cache makes PHPStorm very fast.

My current main development laptop is Lenovo Thinkpad L480 with i5 8250u CPU (4 cores and 8 threads) and 16GB dual-channel DDR4 RAM, with 256GB SSD.

Single project running in one PHPStorm instance can take 300MB to 800MB of RAM. If you run more instances, RAM usage rises, but not by match. With 5 big projects running at the same time (5 instances), RAM usage was around 2GB. In the same time, CPU usage is very low, and only if there is some background scan running, it can start using more CPU time.

Overall, PHPStorm is significantly faster than NetBeans, uses less resources, and for the last 5 months, I never needed to kill PHPStorm process due to the background scanner issues or anything else really.

And the price

Yes, PHPStorm is not free, it has a subscription-based license and you have to pay each month, or once a year. But, the price is fair for what PHPStorm brings to the table. In my case, it has made a lot of things easier, and even with the learning curve that any new software has, my productivity has increased by at least 30% since I have started using it.

They have quick release cycles, with 3 or 4 major updates each year, and each update so far has brought some really nice updates, including support for upcoming PHP 7.4.

Should you use it?

Well, I can recommend to everyone working with PHP and WordPress to try PHPStorm. it has 30 days trial that is fully functional, and that is plenty of time to assess the worth of PHPStorm. Even if you are satisfied with your current IDE, give PHPStorm a try.

Let me know what you think about PHPStorm if you have some interesting experiences with it, or suggestions on how to use it, some tips or even the issues you had with it.

Preparing for WordCamp

I will be speaking on upcoming WordCamp Niš next week, on the topic of Content Security Policy and how CSP can be used to improve WordPress website security.

You can see the detailed schedule for the WordCamp on the official website, and I am scheduled to talk at noon. And, in preparation for the talk, I have released the free plugin on WordPress.org for implementing CSP and various other security headers called GD Security Headers.

GD Security Headers: Dashboard

So, if you are coming to WordCamp Niš, stop by to hear more about WordPress and CSP. In the meantime, check out the plugin.

Saying goodbye to NetBeans

I have been using NetBeans as my main development environment for all my WordPress projects since 2011, and today, I am saddened that that is no longer the case and that I have removed NetBeans from my PC.

When I first started with WordPress development back in 2008 I used Nusphere phpED, but due to high licensing price, I started going through different editors.

NetBeans 7: Big step forward

And, in 2011 I found NetBeans version 7.0 that made it possible to use a single editor for PHP code and for the JS, CSS and HTML. On top of that, it was completely free and with a very vibrant development community, considering it was first and foremost made for Java development.

NetBeans IDE 10.0 – WordPress Project

At the time, I was more than impressed with what NetBeans can do, even if it was Java application that tends to be large and slow, but compared to other solution, that was not really a problem for me. There were issues with version 7.0, but, it was updated very often, and none of the bugs really caused major problems for me.

When I started using the NetBeans, I usually had one or two websites added as development projects, with a smaller number of plugins I was working on. When developing a new plugin, I used a new project to keep things cleaner. But, over time, that changed, and in one time I had over 40 plugins in active development and maintenance, across 10 or more development projects, all loaded in NetBeans.

NetBeans 8: first major problems

When NetBeans 8 was released in 2014, and at the time, I had a lot of projects I worked on, and NetBeans 8 was much better in handling projects then version 7 was, and even higher memory use was not a big deal.

But, the problems started when more complex JavaScript or PHP code with a lot of shared dependencies was used. NetBeans had trouble tracking what comes from where, and since I used shared library of code in all my plugins, this started causing problems:

  • Scanning for changes on startup could take 5 or more minutes
  • Random crashes during the various lookup procedures
  • Scanning JavaScript for changes could freeze the IDE, making typing impossible, code navigation and auto-complete disabled.

And, the only way to resolve all these issues was to kill the NetBeans process and run it again. And, for a while it would work fine (even for days), and again, would start acting up. There were some updates that made things better, but none of the problems were really resolved, and the whole core engine that deals with code scanning felt completely broken, that I had to disable background scanning for changes, making manual refreshes very problematic at time.

NetBeans 9: Apache Takeover, The Last Hope

I learned to work with all the NetBeans quirks, because I was hoping that Apache takeover would solve some very deep issues NetBeans has. So, I delayed switch to some other IDE, and I stick with NetBeans for few more years.

And, NetBeans 9 was released, that I had to skip, because there was no PHP support yet.

NetBeans 10: Nothing really changed

In December 2018, NetBeans 10, with PHP 7 support was released, and I was happy to switch and see how much better it was. And, to my huge disappointment, somehow, it has gotten worse.

Previous problems where the scanning for changes was freezing the IDE are causing more problems even the option for that is disabled (!) and auto complete in CSS and JS often doesn’t work at all. Sometimes when I start the IDE it freezes while checking projects, with high CPU usage, and only killing the NetBeans process and starting again works (and even then, I might need to do this few times before NetBeans can be used).

And, not that these are new problems, they have been reported as bugs way back when NetBeans 8 was first released, and yet, there is no bug fix that works properly.

On top of that, there are other things that should be working, and yet don’t, like no support for newer SCSS versions. Currently only Ruby version works directly, and that is no longer developed. Some addons made for older NetBeans versions don’t work with new one, and authors have abandoned them.

I understand that Apache transition will take time, and so far a lot has been done, but other then some small changes, NetBeans 10 is 95% the same as NetBeans 8, and with all the change in technologies in use today, that is simply not good enough.

Goodbye NetBeans

And, in February 2019, I started looking for the replacement IDE. I tried few things and landed finally on JetBrains PHPStorm. I will write about it in a separate post soon.

For now, I hope that Apache will make NetBeans into great IDE, but with the current development being done, I don’t see much changing in the next few years.

Have you used (or still use) NetBeans? What is your experience with it?

On development and more

Welcome to my new blog!

For the past 10 years, I posted a lot on my main website Dev4Press.com, and it was all related to WordPress development or my Dev4Press plugins for WordPress and bbPress.

Now, I want to write about some other things, still, mostly development related, and other things that I feel don’t belong on the Dev4Press main blog.