PHPStorm: A Love Story


Brian Scaturro
@scaturr
github.com/brianium

Jumping in: Creating projects

PHPStorm offers a short and sweet list of project templates:

  • Empty project  - for when you want to start from scratch
  • Composer project - for when you want the opposite
  • Drupal module - for those who drupal
  • App Engine - leverage Google's App Engine
  • HTML5 Boilerplate
  • Twitter bootstrap
  • Foundation

Composer Projects

Composer projects let you get started quickly

File  > New Project

Installing your Starting Point


Integrating VCS


ENABLING VCS


VCS  > Enable Version Control Integration

Viewing Changes

Changes are grouped in the changes panel

CMD +9   or  click to open

ADDing UNVERSioned files


Click the plus or press (ALT + CMD + A)

Commit that business


VDC > Commit Changes or (CMD + K)

Managing Dependencies

PHPStorm bundles in dependency management with composer.
Its pretty simple. Right click and add dependency

right click project root > composer > add dependency

ASIDE: KEYMAPPNG

Adding dependencies is common enough that we might want to create a shortcut for that:

PHPStorm > Preferences > Keymap

File Templates

Templates are a nice way to create configurable files based on existing code. Great for common tasks.

Some built in templates include:
  • PHP Classes
  • PHP Traits
  • PHP Interfaces
  • PHPUnit tests
  • JS Files

CREATING Templates


PHPStorm > Preferences > File and Code Templates

Template variables

Variables of the form ${VARNAME} allow for customization when a file is created:

Unit Testing

A fully integrated test runner and a slew of test helpers makes PHPStorm a valuable tool for test development.


New > PHPUnit > PHPUnit Test

ASIDE: Shortcuts

PHPStorm provides a lot of useful shortcuts for generating methods and implementations.

CMD + N

Creating a test configuration

If we are going to be running tests frequently, we will need to set things up so PHPStorm knows how to run our test suite:


Preferences > PHP > PHPUnit

Running tests

To run the current test, just press  CTRL + SHIFT + R

If you get this you will need to click "Fix" and point PHPStorm to your PHP install:

Test results are shown in the "Run" panel:


At any point in your project, you can hit CTRL + R to run what was run last

Navigation

Navigating between files and classes is pretty painless
  • CMD + O - navigate to class
  • CMD + SHIFT + O - navigate to file
  • CMD + ALT + O - navigate to symbol

REST CONSOLE

Everything is APIs these days, it would be nice if we could test our APIs without leaving the comfort of our IDE:

Tools > Test RESTful Web Service

ASIDE: TERMINAL

PHPStorm provides access to an OS terminal. This is ideal for running simple tasks and starting servers:

Debugging

Set break points, and step through code like one of the cool kids!
The folks at JetBrains have a ready made play by play for configuring xdebug and using it within PHPStorm:

Creating aN Application configuration

Just like we created a PHPUnit configuration so we could run tests, we do the same for a web application.


Run > Edit Configurations + PHP Web Application

Creating a server configuration

Our application configuration requires a server configuration:

Setting BREAKpoints

We set breakpoints to pause execution and take a peak at the current environment while an application is running:
Click gutter or press cmd+F8

STEPPING Through breakpoints

Instead of CTRL + R to run, we use CTRL + D to start a debug session.

When execution hits a breakpoint we should see the following:

SHORTCUTS

There are shortcuts for stepping over and through debugged code, line by line:

  • F8 - Step over
  • F7 - Step into
  • ALT + CMD + R - Resume program

OTHER Cool Features

There are so many awesome features of PHPStorm, it would be impossible to cover them all in a short period of time. Things like:

  • Gist integration
  • CTRL + T refactoring shortcuts
  • Front end helpers (WebStorm)
  • Profiling
  • Code structures
  • SO MUCH MORE

Questions?

PHPStorm: A Love Story

By Brian Scaturro

PHPStorm: A Love Story

A non-exhaustive showing of PHPStorm for php development

  • 2,287