Atom Beautify
In Atom-Beautify, format/beautify on save can be enabled or disabled for each language individually. For example, for language HTML go into Atom-Beautify's package settings ( Atom Preferences Search for atom-beautify), find HTML, and toggle the Beautify On Save option. Atom-Beautify is an Atom plugin which helps you reformat the codes, make your codes easier to see and more beautiful. There is a list of document types supported by Atom-Beautify, which consists of.
Or Settings/Preferences Packages Search for atom-beautify. Looking at the list of issues on Atom Beautify, at the time of writing this, there are 51 open and 155 closed. I see and strongly feel that Atom Beautify needs a more love than I currently have allocated time. I am trying to install an add-on to clean up my PHP called Atom beautify. Every time I run the plugin to make my PHP file pretty (Atom Beautify) I get this showing up: Error: spawn EACCES at expo.
Atom is an advanced open source text editor for developers.This article will explain some useful packages and tricks how to make the mostout of it when developing with PHP.
IDE or editor?
First, a bit of an introduction and comparison between IDE (integrated developmentenvironment) and editor. IDE provides more functionality out-of-the-box comparedto an editor. So why would you want to use an editor in the first place?
Editor usually requires less computer resources and can work faster compared toan IDE. Also the learning curve and time to get used to an editor is less steep.And on top of that editor can still be customized with additional packages to behavea lot like an IDE.
One of the recommended ways to develop applications is for example, to use an IDEfor developing the project at large and an editor for quick edits across differentprojects or folders. However you can successfully develop PHP projects alsowithout an IDE. Explore and try different tools to see what suits your developmentworkflow. Make sure that the tools you use, make you productive.
Atom installation
Installation of Atom is as simple as it gets and works on all widely used operatingsystems (Linux, Windows and macOS). Visit the Atom homepageand the releases on GitHub to downloadthe installation for your system.
Themes
By default, Atom comes with multiple nice themes you can use out of the box.Additional themes can be obtained from Atom themes repository.
Configuration
Nice thing about Atom is that it can be customized to do almost anything.Configurations can be set via the menu Edit > Preferences
.
The configuration files are saved in your home directory ~/.atom
, so you canbackup them to your dotfiles and have a portableconfigured development environment for multiple development machines.
Some of the portable files in that folder are config.cson
, keymap.cson
,snippets.cson
, and styles.less
. The installed packages can also be exportedto a custom list file via command line:
When you will need to reinstall Atom, the saved packages list can be used to quicklyinstall all your favorite packages:
Code style
By default, Atom already supports syntax highlighting and snippets for a lot oflanguages. For PHP it uses the language-phppackage. To set your preferred coding style such as spaces/tabs, line ending, andsimilar go to Edit > Preferences > Packages
and type language-php
and setsome default behaviors you use. In the following section we’ll check some packagesthat can improve and extend managing code style in your PHP project.
Packages
Atom packages extend core editor functionality. They can be obtained fromthe Atom packages repository.
Packages can be installed via the GUI Edit > Preferences > Install
or with thecommand line Atom package manager apm:
By default, Atom provides basic editing capabilities and everything you need towrite PHP code. There are many packages to extend and make writing PHP codemore efficient and provide a much better development experience. If you are usedto some advanced IDE functionality already, you’re familiar with things such asautocompletion, code inspection, generating code snippets and more. There area lot of Atom packages for PHP development, however you might want to take a lookat some of the following highlighted packages for having PHP development moreefficient.
Atom Beautify Shortcut
Atom beautify
Did you get a code that is not suited for your coding style? Theatom-beautify package is a must checkfor having a consistent code style and to beautify the code on the fly. It cleansthe code for multiple languages according to the predefined code style settings.To successfully beautify PHP code, you must also separately install either thephp-cs-fixer or thePHP Code Sniffer.
Editorconfig
To have a consistent code style across different editors for multiple people, youmight want to take a look at Editorconfig initiative.The editorconfig package adds supportfor .editorconfig
file to Atom.
PHP Integrator
PHP Integrator is a collection of multipleAtom packages to provide a better PHP development experience. To install andsuccessfully use PHP Integrator packages you will first need to install someprerequisites:
- PHP
- php-sqlite extension
- openssl
- project-manager package
- php-integrator-base package
After base PHP Integrator installation save your PHP project in Project Manager(Packages > Project Manager > Save Project
) and index it with PHP integrator(Packages > PHP Integrator > Set Up Current Project
) which will index projectfiles for further usage.
PHP Integrator and Linter inspect and validateyour PHP code for errors, checkPHP DocBlocks and more.
PHP Integrator shows tooltips (e.g. for methods and classes) in your PHP sourcecode.
PHP Integrator includes call tips with parameter information in your PHP sourcecode for functions and methods.
With PHP Integrator installed and project prepared, you can check the followingadditional packages from PHP Integrator collection:
PHP Integrator Autocomplete Plus
The php-integrator-autocomplete-pluspackage provides autocompletion for your PHP source code. By indexing project files,autocompletion works also for classes from project and Composer’s vendor folder.Class is automatically added to the list of used classes on top of a currentPHP file.
PHP Integrator Navigation
The php-integrator-navigationpackage provides code navigation and go to functionality for your PHP source code.For example, clicking a class opens the source code file. Opening can be done byadjusting the settings (
Alt
+ left mouse click,Shift
+ left mouse click orsimilar).PHP Integrator Refactoring
The php-integrator-refactoringpackage provides refactoring capabilities for your PHP source code. It generatesgetters and setters for PHP classes and similar. Keybinding:
Alt
+Enter
.PHP Integrator Annotations
The php-integrator-annotationspackage shows which methods override their interface implementations.
PHP Debug
The php-debug package is PHP code debuggingpackage using the Xdebug extension.
PHP Server
The php-server package runs PHP developmentserver on your localhost.
Above we’ve gone through some of the useful packages for PHP. To improve developmentexperience and add additional functionality you might want to check these awesomepackages.
Minimap
The minimap package adds file preview on thesidebar. Once you get used to it, it is a must have package in your collection.It is useful for easier overview of the source code and quicker navigation overthe file.
Highlight Selected
The highlight-selected packagehighlights the current word selected when double clicking. If you’re using theminimap package there is alsominimap-highlight-selected.
Atom Minify
The atom-minify package minifies JavaScriptand CSS files. It is useful when you come across a need to manually quickly minifya required file on the fly.
Todo Show
The todo-show finds all TODO
, FIXME
,CHANGED
and similar comments in your project and shows them in a nice overviewlist.
Color Picker and Pigments
The color-picker package opens colorpicker for color codes such as HEX by using right click or pressingCMD-SHIFT-C
/CTRL-ALT-C
. Pigments displayscolors for color codes in the editor itself.
Ctrl-dir-scroll
The ctrl-dir-scroll package is convenientfor users who are used to shortcuts from some other IDEs and editors. By default,Atom uses Ctrl
and up/down keys to move the line up and down. This package addsscrolling up and down with keyboard - CTRL
and up/down keys.
Project Manager
The project-manager package helps youmanage multiple projects.
Emmet
Emmet adds support for Emmet.
Docblockr
Docblockr is a helper package for writingdocumentation.
File Icons
The file-icons package adds icons in treeview for recognized file types.
Framework specific packages
Atom-beautify Download
PHP frameworks are supported by multiple packages which provide additionalfunctionality such as code snippets.
Docker
Developing with different PHP installations, extensions and dependencies soonrequires virtualization and/or containerization such as Docker. Docker can beoptionally integrated in Atom with additional plugins:
Adds Dockerfile syntax highlighting.
Integrates Docker with Atom editor.
Shortcuts and useful features
Keyboard shortcuts can make you more productive. These are some of the keyboardshortcuts you might find useful. On Linux and Windows use the Ctrl
key, and onmacOS the Cmd
.
Comments:
Ctrl
+/
Comments/uncomments selected code.
Find and open a file:
Ctrl
+p
Command Palette:
Shift
+Ctrl
+p
Command palette simplifies access to find and run available commands insteadof going through the menu manually.
Multiple cursors:
With
Ctrl
and left mouse click you can add more cursors to the editor whichbehave the same as a single cursor. This is useful for changing multiple samevalues on different parts of the file.
Caveats and final thoughts
Performance
Having installed and enabled a lot of packages might also slightly slow down theperformance. When opening very large files (few MB), the editor performance candecrease and the editor becomes unresponsive. Currently Atom supports files upto few MB (~10MB), and works a bit better on Linux and macOS systems. This hasbeen already noted on Atom issue tracker,so it might be fixed in the future.
How to deal with the issue of very large files (for example, log files)?
Many GUI editors and IDEs have same issues when opening and working on large files.People usually solve this with the command line tools like grep
, cat
, head
,tail
, and sed
. For compressed files there are also zless
, zmore
, zcat
,and zgrep
.
Learning curve
At first, Atom might seem a bit overwhelming, specially to fine tune it for yourneeds. So, as with every tool, take some extra time and read thedocumentation to get to know it in more details.
Multiple community packages can have the same keybindings and in this case needto be reconfigured manually.
Which packages to install and which not is your choice and preference. For PHPdevelopment in particular, many tasks can be done by using native tools inthe command line instead of using editor plugins. For example, unit testing,running Docker containers, deployment, running up local development server andsimilar.
Atom truly is a magnificent editor worth taking a look. It has a huge communitybehind and it is open sourced.
See also
Some additional useful resources:
- Atom Flight Manual - Official book about Atom.
- Atom in Orbit - Atom in thebrowser.
- Awesome Atom - A curated list ofdelightful Atom packages and resources.
- Nuclide - A package built on top of Atom for React Native,Hack and Flow projects.