Which is better WebStorm or Atom

Atom: With the right packages for the perfect PHP editor

Are you not too happy with PHP Storm, Netbeans and the like and prefer a somewhat “lighter” editor for PHP development? I consider myself one of these people. And since I have become very friends with the Atom editor, I have set it up in such a way that it also works well for PHP development. Today I want to show you how my Atom setup for PHP is structured.

Basic equipment

First of all, of course, we need to make sure that Atom is installed. In its basic configuration, the editor does not yet have that much functionality, but it impresses with its speed and simplicity. In addition, it can be easily expanded thanks to a sophisticated plug-in system.

Add-on packages can be installed either directly via the editor or via the command line. For the development of PHP projects we should now install two basic packages that we will need later:

  • Project manager: Is required to easily define projects in Atom.
  • php-integrator-base: Lays the foundation for some plugins that simplify the editing of PHP code in Atom.

As described on the official PHP integrator website, the project can now be initialized as follows:

  • We initialize the project via «Packages»> «Project Manager»> «Save Project».
  • Via «Packages»> «PHP Integrator»> «Set Up Current Project» we define the project as a PHP project.

The entire project is then automatically indexed and nothing stands in the way of using further plugins.

Autocomplete

With the “autocomplete-plus” package, Atom offers its own solution for beautiful autocompletions that replaces the standard mechanism. Usually the package is already installed and active. If that is not the case, we will make up for it.

However, the package is only a so-called «provider» which can be used by other packages. By default, Atom does not know how to complete PHP code. The «php-integrator-autocomplete-plus» plug-in, which is based on the «php-integrator-base» package that has already been installed, helps us here.

PHP autocomplete in the Atom editor.

The package offers some features:

  • Autocompletion for local variable names.
  • Autocompletion for global functions and constants.
  • Autocompletion (snippets) for tag names in docblocks.
  • Autocompletion for class, interface and trait members.
  • Autocompletion for class, interface and trait names as well as their constructors.
  • Automatic adding of use statements when class names are autocompleted (with a somewhat intelligent positioning).
    • Included is a command to sort the current use statements.

navigation

We are used to real IDEs that we can click on variables or functions and then automatically end up with the appropriate definition. This functionality can also be added with a suitable plugin.

First of all, we need the «hyperclick» package, which also only functions as a provider and can be used by other packages. After we have installed «hyperclick», we can install the «php-integrator-navigation» package, which implements this functionality perfectly for PHP code.

We can now select methods, functions, variables and classes with the key combination «Ctrl / Cmd» + «Click» and thus automatically end up with the corresponding definition. According to README, the package offers the following functions:

  • Navigate to the definition of your global PHP constants and functions.
  • Navigate to the PHP documentation of built-in classes and functions by alt-clicking them.
  • Navigate to the definition of classes, traits and interfaces by alt-clicking them.
  • Navigate to the definition of class, trait and interface members by alt-clicking them.

Linter

Opinions differ on the subject of linting. Personally, I think it makes sense for the editor to point me directly to coding style violations. If you find this as practical as I do, you can get the right functions in Atom with the following packages:

  • Linter: The provider package.
  • linter-phpcs: A linter based on PHP_CodeSniffer.
    (Danger: PHP_CodeSniffer must already be installed.)
  • php-integrator-linter: Another linter who can detect additional violations - such as inaccuracies in docBlocks.

PHP linter in the Atom editor.

More packages

The most important packages that make Atom a perfect PHP editor are now installed. If you search for “php-integrator” in the available packages, you will find countless other interesting packages that are not mentioned in this article.

Which package can you no longer do without? I look forward to your comment.