Before you go, check out these stories!

0
Hackernoon logoA Complete Guide to PHPStorm Setup for Magento 2 by@rickdaalhuizen90

A Complete Guide to PHPStorm Setup for Magento 2

Author profile picture

@rickdaalhuizen90Rick Daalhuizen

Web developer, Linux enthusiast, father and husband. I like to write about programming.

As a Magento developer, you are dealing with a complex code-base that you have to navigate through. That is why it is useful to have an IDE (Integrated Development Environment) that helps you write your code and ensure its quality.

Perhaps one of the most famous IDE for PHP developers is PHPStorm. PHPStorm comes out of the box with all the tools you need for writing PHP applications. Here are some tips and tricks about my PHPStorm configurations that I use as a Magento Developer on a daily basis.

I will not cover the following: keyboard shortcuts, fonts, and color schemes, since they will be different for everyone. Eventually I will share my settings.zip with you for download.

Go to the menu bar and hide what you don't need:

Show options menu

✔ Compact directories (Ensures less nesting of empty folders)

View > Appearance

Hide the following:

☐ Tool Window Bars

☐ Status Bar

☐ Navigation bar

Then go to Phpstorm -> Preferences or open "Preferences" with the key combination ⌘ + ,

Appearance & Behavior > Appearance

☐ Animate windows

☐ Show tool window numbers

☐ Allow merging buttons on dialogs

☐ Show tool window bars

☐ Disable mnemonics in menu

Appearance & Behavior > System Settings

☐ Reopen last project on startup

☐ Confirm application exit

✔ Open project in new window

Editor > General > Breadcrumbs

☐ Show Breadcrumbs

Editor > General

☐ Enable Drag and Drop functionality in editor

☐ Show notification after reformat code action

✔ Ensure line feed at file end on save

Directories:

Exclude files:

.github;.idea;generated;phpserver;pub;setup;update;var

This gives us a more organized folder structure with only the folders we care about.

Plugins

I like to keep it as minimal as possible by only installing essential plugins, these are as follows:

  1. IdeaVim - Vim emulation plug-in for IDEs based on the IntelliJ platform
  2. Magento PhpStorm - Official Magento PhpStorm plugin for Magento 2
  3. MaGinto - Plugin, created to improve life-work balance while working with Magento 2
  4. PHPAnnotation - Extends PhpStorm to support annotations in DocBlocks
  5. Symfony Support - Support for Symfony framework / components.
  6. BashSupport - Adds extra support for bash scripts
  7. CSV Plugin - Lightweight plugin for editing CSV/TSV/PSV files
  8. .​env files support - easy support for dotenv files
  9. Solarized Themes - Adds Solarized Dark and Light color themes.

Configure PHP Codesniffer (phpcs), PHP Mess detector (phpms) and PHP CS Fixer

⌘ +, Language & Framework -> PHP -> Quality tools -> PHP CodeSniffer -> …

  1. PHP_CodeSniffer path:
    <Magento_Root>/vendor/bin/phpcs
  2. Path to phpcbf:
    <Magento_Root>/vendor/bin/phpcbf
  3. Click the "Validate" button to make sure everything is set-up right.

Repeat the same steps for Mess Detector and PHP CS Fixer. You can find these files under:

<Magento_Root>/vendor/bin/

And lastly, don't forget to backup your configuration by going to Files -> Manage IDE Settings -> Export Settings, you can download mine in here.

This is the end of my blog, if I missed something or you have any settings you want to share, please leave a comment below.

Previously behind paywall at: https://medium.com/dev-genius/the-complete-phpstorm-setup-for-magento-2-7776d4156c1e

Tags

The Noonification banner

Subscribe to get your daily round-up of top tech stories!