If you are a developer, then you will definitely know what an IDE is and how it helps to code easier and faster.
For PHP developers, the best IDE available in the market is PhpStorm, a product from JetBrains that is similar to IntelliJ IDEA for Java&JavaEE, it offers a Fast and Safe Refactoring, a Smart Code Navigation, an Intelligent Coding Assistance and an Easy Debugging and Testing.
If you use Symfony PHP Framework, then I recommend you to use Phpstorm because it has a lot of plugins, live templates and tricks (described below) that will make your life easier and will help you to generate your repetitive code snippets quickly.
This article admits that you know how to manage plugins in PhpStorm, if you don’t then check this documentation.
Symfony Plugin:
A great PhpStorm plugin for Symfony2 and Symfony3 users, it is installed one time but must be enabled and configured in each Symfony project you use.
It provides advanced IDE features for Symfony-specific navigation, code completion, Quick-fixes, support for Twig templates, service container, Doctrine, translations, Symfony routes, Symfony forms, Symfony events, Symfony command line tool, code style, and much more.
This plugin becomes very popular in PHPStorm repository with more than 1,4M downloads.
Services Example:
Twig Example:
More examples and details in the Official page
PHP Annotations Plugin:
This plugin offers a lot of features, especially code completion, and quick-fixes.All the available features until now:
- Attach PhpClass to their DocTag to support “Code > Optimize Imports”
- Auto alias detection on use statement
- Filter annotation classes on targets like method, class, property, …
- Goto for doc tags and property names
- Detect annotation property values on phpclass property name including types
- Index classes with @Annotation inside doc block
- Plugin extension point
- Doctrine related providers
- Class import annotator
- Class constants in DocTags
- Doctrine ORM intention and quick fixes for repository and properties
More examples and details in the official page
PhpStorm Live templates for Symfony:
Live templates for Symfony 2 and Symfony 3 are a list of shortcuts to help you write code snippets quickly.
The starting list includes:
action
(inside a controller): Builds an action method (GIF Above)404Unless
(controller): Adds an if statement with a 404formhandle
(controller): Adds form-handling boiler-plate codeformrow
(twig): Rendersform_row(form.???)
formrowfull
(twig): Renders the widget, label and errors for a fieldinclude
(twig): Adds{{ include('???') }}
method
(controller): Adds@Method
annotationpath
(twig): Adds{{ path('???') }}
render
(twig): Adds{{ render(controller('???')) }}
rendertwig
(controller) Adds$this->render('???')
repofind
(controller) Adds$this->getDoctrine()->getRepository('??')->??()
route
(controller) Adds@Route
annotationservice
(yaml) Adds the basic YAML service definition structuretags
(yaml) Adds atags
line to a service
Emmet( Zen-Coding):
This plugin is installed and enabled by default once you install PhpStorm,it is available in a lot of text editors and IDEs, not only PhpStorm.
It’s an abbreviation engine that has a modular structure which allows you to expand abbreviations into different languages. Emmet currently supports CSS, HTML, XML/XSL.
Example:
This line:
div#page>div.logo+ul#navigation>li*5>a
Can be expanded into:
<div id="page"> <div class="logo"></div> <ul id="navigation"> <li><a href=""></a></li> <li><a href=""></a></li> <li><a href=""></a></li> <li><a href=""></a></li> <li><a href=""></a></li> </ul> </div>
Have other tools to boost your productivity, share them with us in the comment section below.