How to setup Atom for PHP Development

What is Atom and why it is awesome?

Atom is a hackable text editor. I normally don’t like the idea of text editors which need settings and different plug-ins installations to be some what equivalent to a complete IDE but after using Atom with some configurations and plug-in installation, my opinion is changed.

What now I think is that a hackable editor is actually good because it provide you option to only have functionality what you exactly need while still being very light-weight.

Using Atom as PHP IDE:

I came to Atom from Netbeans, when it became very slow and made overall system very slow. I never liked Netbeans’ non-smooth fonts on Ubuntu but didn’t find any good option. But after slowness issue, I tried Atom as text editor and then found it much more powerful by utilizing packages available. So now I use it for PHP development with useful features without making my system slow.

Please note that these packages will not make it equivalent to a premium tool like “PHP Storm”( in fact never compare other IDEs with JetBrains’ IDEs unless you don’t want to pay 100$+ for IDE. ), but still Atom with packages will be better experience in many ways as compared to other editors and IDEs. If you are currently using some text editor like notepad++ or brackets, or tools like Aptana or Eclipse, you will like Atom with these packages. And obviously your system will feel much better if you are coming from Netbeans.

Installing Atom:

Simply go to https://atom.io/ and download the build for your release and then simply install it. It don’t have any hard dependency like Netbeans need JRE. By just installing Atom, you can start using it as a simple text editor with smoother fonts and awesome themes.

Atom for JS:

Most of PHP developers also need to interact with JS and front-end. So you will want JS support as well. Atom come with some JS related packages already installed with Atom.

Atom Settings and packages:

To see atom packages, themes and other configurations then go to:

Top menu > Packages > Settings View > Open

or

simply press ctrl + , (control and comma key)

You should see this settings screen:

Now scroll down and find field labeled as Tab Length” and change its value to 4 instead of 2 as per PSR2 standard. ( http://www.php-fig.org/psr/psr-2/ )

Atom Packages:

In atom, you need to install packages to extend Atom and have more feature set. Here are some important packages listed below with their detail. Please note that Atom package can be installed using settings window as well as this command:

$ apm install <package-name>

PHP CS Fixer:

csfixeronsave

PHP CS fixer runs the “PHP Coding Standards Fixer” within your Atom Editor. Install this package but it will not start functioning. This package requires the “PHP Coding Standards Fixer” Cli build by SensioLabs wich can be installed using composer:

$ ./composer.phar global require fabpot/php-cs-fixer

Above package is abandoned so this one can be used:

$ ./composer.phar global require friendsofphp/php-cs-fixer

then go to settings provide path to php-cs-fixer and PHP. Also click on “Execute on Save” check box so that on save, it will format it according to psr2 standards.

Linter PHP:

linter-php error screen
linter-php error screen

Install this package so that your Atom know in case of any PHP syntax error  you make. It will show you proper error within your editor. This is very important unless you used to write PHP in conventional text editor.

It will work without any further settings if your php is accessible globally through command line. Otherwise you will need to provide PHP executable path in this package’s settings.

PHP Hyperclick:

Hyperclick provider for PHP. Open file when classname is clicked. This is simple and very useful package but installing it alone will not work. So you will also need to install dependency  that is Hyper Click (another package of Atom).

In case if it don’t work with “ctrl+click ” then try “alt+ctrl+click” .

Last words:

These are just few packages that I have installed and made my Atom editor  better, at least I no more miss Netbeans (which I was using for last ) for doing some work in modern framework like Laravel. But I expect a lot of more awesome surprising packages other than these. So keep exploring and let me know about your favorite atom packages in comment.

 

20 thoughts on “How to setup Atom for PHP Development”

    • last time it did’t work when I tried to use it on ubuntu on your request. So stop marketing it this way. First ask professionals (or even pay them if necessary) to use your tool and ask about feedback. Once this step is done then next step is spreading. In fact, if your tool will be good they will probably spread the word for you for free. I wrote this article because I was using and I liked atom at that time. Now I am using VSCode so probably I will write about that as well. I even mentioned PHPStorm which is paid tool only because it is good.

      Reply
  1. I found this article very helpful in setting up Atom for PHP.
    Please consider updating it:

    Package fabpot/php-cs-fixer is abandoned, you should avoid using it. Use friendsofphp/php-cs-fixer instead.

    Reply
    • Nowadays, I am using VS Code only because, Jeffrey Way shared some good tricks on laracasts about VS Code. However, it has its own cons as well.

      Reply
  2. I actually moved away from PHPStorm to Atom. PHPStorm is way too bloated and clunky at this point. It felt like having to break out the mission control manual to do almost any simple task. Atom.io, is straight forward, and throwing on packages as you need features seems like a much more organic way to learn an IDE.

    Reply
  3. This package requires the “PHP Coding Standards Fixer” Cli build by SensioLabs wich can be installed using composer:

    $ ./composer.phar global require friendsofphp/php-cs-fixer

    How to go here?
    And what do you mean by Composer?

    Reply

Share your thoughts