Skip to content

Instantly share code, notes, and snippets.

@hofmannsven
Last active December 20, 2023 09:46
Show Gist options
  • Save hofmannsven/2c300b0b66828e0fba5e to your computer and use it in GitHub Desktop.
Save hofmannsven/2c300b0b66828e0fba5e 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
  • Navigate backwards with caret: cmd + [
  • Navigate forward with caret: cmd + ]
  • Jump to current file (Scroll from Source): alt + F1 > 1 or alt + F1 > enter
  • Open file: cmd + shift + o
  • Jump to the navigation bar: cmd + ↑

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