PHP Code Completion in Atom Editor

Tawsif Aqib
4 min readSep 5, 2016

--

I was a Sublime Text fan. I still am, but I am just a bit bigger Atom fan now! Being a PHP coder I have found Sublime Text as an awesome text editor which has packages like Sublime PHP Companion, CodeIntel and many more which help me to write PHP code by providing Code completion and navigation. 1 year ago Atom drew my attention with its support for lots of different languages, tools integration, customization and most of all the Open Source tag. But I could not find any alternatives for those amazing packages of ST3 which helped me write PHP code in an efficient way.

Recently I have found a group of packages for Atom which is actually helping me to write PHP in even more efficient way than ST3.

Lets not waste anymore time and get right to those packages.

project-manager

Project Manager helps to get easy access to all your projects and manage them with project specific settings and options (took right from their readme).

Open your project directory in Atom and press cmd+shift+p and select Project Manager: Save Project then write the name for your project. Now you can automatically open your project in Atom by navigating to the project list by pressing cmd+ctrl+p and selecting your project.

This package and project saving is a prerequisite for the next package. You can (should) visit the package website page for further information.

php-integrator-base

This is the main package that does the indexing of your PHP code. Install it and then press cmd+shift+p and select Php Integrator Base: Setup Current Project. You need to save the project in Project Manager shown above before indexing. This will complete the indexing and prepare your project for the next packages.

Whenever you add a file to to your project, or add a composer package or even remove something, you might want to press cmd+shift+p and run Php Integrator Base: Index Project to add the new files to the index.

php-integrator-autocomplete-plus

First of all, you might want code completion because it is just too boring to type the class name with its long namespace! This package will help you by suggesting those class names with namespace so you don’t have to remember those and put more concentration on your logics and less on memorizing and navigation.

php-integrator-navigation

I know that you also need code navigation. Like you want to move to the class when you click on its usage or the function definition when you click on the usage right? Install this package and you will be able to do all these, Just press option key in mac and click on the usage.

php-integrator-tooltips

Would you like to have a tooltip when you hover over a class, method or property? Think no more. Just check out below and if you like it then install this package without delay.

php-integrator-call-tips

But you still need help when you use a method or function because you can’t remember the parameters. Don’t feel low because I can’t remember either! This package will give you enough information to remind you those parameters along with their types. Check out below if you are still in doubt.

php-integrator-refactoring

Well everything was awesome and I was writing code like a beast until my team lead came and asked -

But does it have code refactoring?

Took me 5 minutes to find the solution. Installed this package and now I am selecting a code block, pressing option+m, moving it to a function and refactoring like a boss!

Conclusion

There are more packages starting with php-integrator-* name. But I have not yet explored those. For now I am just happy to be able to use Atom as my PHP code editor.

PS. If you are wondering how I am able to change the color of those tooltips — It is because I edited Atom’s stylesheet (style.less) and added these lines -

.php-integrator-call-tip {
.tooltip {
.php-integrator-call-tip-wrapper {
color: #c5c8c6;
background-color: #21252d;
}
}
}
.php-integrator-popover {
.tooltip-arrow {
border-bottom-color: #21252d !important;
}
.tooltip-inner {
background-color: #21252d;
}
}

I am using One Dark UI theme with Spacegray Dark Neue syntax theme and Fira Code font with ligatures.

The End!

--

--

Tawsif Aqib

Lead Engineer from Bangladesh, living in the Netherlands with decade of experience in software development, architecture and engineering leadership.