I'm available to work on new projects starting June 2017! Get in touch!

Back to post list

Using PHPStorm to develop php applications


Developing PHP applications requires a solid environment. A long time ago I used Sublime Text for this task. Granted, Sublime Text is very fast, but it required a lot of additional plugins to handle some basic operations like importing classes.

Installing all these plugins made my Sublime Text editor a lot slower than it used to be. That's when I started looking for better alternatives.

It didn't take long to stumble uppon PHPStorm an IDE developed by JetBrains.

The biggest difference between Sublime Text and PHPStorm is first and foremost the type of software, the first is a text editor and the latter an IDE, aka integrated development environment.

PHPStorm, is built specificaly for php applications (I'm sure you guessed that already). Meaning that it has a lot of productivity features regarding PHP.

Need to find a particular class ? No problem search for a class name.

Need to find a particular method ? No problem search for that method only.

It has features like "command clicking" on a class to navigate to that class, a helper window to display all methods and properties of a specific class. These make developing modern PHP applications using PHPStorm a enjoyable experience.

Refactor much ?

Another set if features it has, and that I use daily, is PHPStorms refactoring abilities.

Take this code for example:

public function create(array $data)
    return $this->model->create([
        'first_name' => 'John',
        'last_name' => 'Doe',

This is a quick method belonging to a repository class creating a user. Now let's say you wanted to trigger an event when a user is created. You'd have to assign the call to the create method to a variable, trigger the event while passing that variable and finally return the $user variable.

With phpstorm this is very easy to do. Simply select the $this->model->create method completely, press ctrl + t (or Refactor menu > refactor this), select "Extract variable", and you're done. PHPStorm automatically reformatted to code like so:

public function create(array $data)
    $user = $this->model->create([
        'first_name' => 'John',
        'last_name' => 'Doe',
    return $user;

This seems trivial but is very useful on daily use.

Take the time to experiment with the "Refactor" menu, it has many nice features.

  • Extracting methods,
  • Extracting variables,
  • Changing method signatures (and also changing in all usages),
  • Moving methods,
  • Renaming classes (while also renaming file name and all usages of that class)
  • Renaming methods/properties + all usages,
  • and many more.

Version Control

PHPStorm also removes the need for an external software (terminal or dedicated) to handle version control, for instance git.

It has a full GUI for handling almost all version control actions.

Personally though, I'm not a fan of GUI's since they're usually a black box, not knowing what they do behind the scenes.

This is why I only use PHPStorm's commit and push features via GUI. The rest I handle via the terminal.

For this too, I don't have to leave the app, PHPStorm has a integrated terminal!

Code completion

This is probably the biggest and most used feature. Whenever you're in a class and you start typing for a property / method, PHPStorm will try its best to autocmplete those names.

In the same manner, whenever you typehint a class in a constructor for instance, PHPStorm will autocomplete it, but it will also import that class automatically.

Usually when importing a class in a constructor you also want to asign that variable to a class property, PHPStorm got you covered!

And much more

  • Macros
    • Record several key strokes after each other, assign this macro to one key, save yourselfs meny key strokes.
  • Live templates (snippets from Sublime Text)
  • Live debuging inside the application with xDebug
  • Vagrant integration
  • Composer integration
  • PHPUnit integration
  • ...

Saving time and avoiding bugs

All these features help us as developers to develop faster and with less bugs. By going to the Help > Productivity Guide window, phpstorm summerises the time saved and bugs avoided.

Stop wasting your time and try out PHPStorm today. It's free for 30 days.

Laracasts has an awesome getting started with PHPStorm video series to jump start you right in.

I'm available to work on new projects starting June 2017! Get in touch!

"Tackling software estimates" Exporting Relations diagram from Sequel Pro