Skip to content

Instantly share code, notes, and snippets.

@Jeket
Forked from hofmannsven/README.md
Created August 9, 2019 09:51
Show Gist options
  • Save Jeket/4e0cbe5d1129429384b2725393ca0ec4 to your computer and use it in GitHub Desktop.
Save Jeket/4e0cbe5d1129429384b2725393ca0ec4 to your computer and use it in GitHub Desktop.
Notes on working with JetBrains PhpStorm IDE on macOS.

PhpStorm

Tutorials

IDE Helpers

Theme

Documentation

  • Quick docs: F1
  • External docs: shift + F1
  • Method parameter information: cmd + p
  • Search in Dash: cmd + shift + d (requires Dash plugin)

Shortcuts

Basics

  • Paste from history: shift + cmd + v

Selection

  • Expand selection: alt + up
  • Multiple cursors: alt + click (add and also remove)
  • Select next of kind: ctrl + g
  • Select all of kind: ctrl + cmd + g
  • Move selection: alt + shift + up / alt + shift + down
  • Remove line: cmd + backspace

Search

  • Search everywhere: shift + shift
  • Search for action: cmd + shift + a

Refactor

  • Refactor: ctrl + t

Format

  • (Re-)Format code: alt + cmd + l

Create & Scaffold

  • Duplicate line: cmd + d
  • Create new file: cmd + n (within project sidebar)
  • Create temporary scratch file: cmd + shift + n
  • Scaffold code: cmd + n (within object)
  • Initialize fields: alt + return
  • Quickfix: ctrl + return
  • Import class namespace: alt + return

Structure & Navigation

  • Show structure of current file: cmd + F12
  • Select recent files: cmd + e
  • Jump to declaration: cmd + b
  • Jump to previous caret (text cursor) position: alt + cmd + left
  • Jump to next caret (text cursor) position: alt + cmd + right
  • Jump to current file (Scroll from Source): alt + F1 > 1 or alt + F1 > enter
  • Open file: cmd + shift + o

Debug (Xdebug required)

Autocomplete for external libraries

Add the global path as external library or require it via composer.

  • External library: /Applications/MAMP/Library/bin
  • Composer dependency: "phpunit/phpunit": "5.6.*"

PHP Code Sniffer

Install

  • composer global require squizlabs/php_codesniffer
  • Alias: alias phpcs="/Users/username/.composer/vendor/bin/phpcs"

Activate

  • PhpStorm: Settings » Editor » Inspections » PHP » PHP Code Sniffer validation (PSR2)

Configure

  • PhpStorm: Languages » PHP » Code Sniffer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment