PhpSpec Live Templates for PhpStorm

During PhpSpec & PhpStorm webinar recorded together with JetBrains I've mentioned couple of times how Live Templates can speed up your development.

Personally on daily basis I'm using templates I've created for PhpSpec and shared after the webinar but since then I've improved those and would like to share it with you guys.

Why do I need Live Templates?

As we know typing skills are as fundamental for programmers and also mastering your environment makes you a better developer. Because of that it is your professional responsibility to be efficient at work, and you don't want to waste time thinking how syntax looks like, don't you?

Live Templates will speed up your development and simply make you more efficient. Also second benefit from using those particular is the fact they will ease your PhpSpec learning curve.

How to use it - examples

Using Live Templates is quite simple - just type its abbreviation and expand it with Tab.

Inserting example skeleton - ex


Inserting example set up - let

Inserting type expectation - sbi

Supported abbreviations

Usual pattern for most expectations abbreviations is quite intuitive - first letters of used words. Only exceptions are sbi and snbi - that's just for convenience.

  • ex - example skeleton
  • let - example set up
  • letgo - example tear down
  • sb - shouldBe
  • sbc - shouldBeCalled
  • sbet - shouldBeEqualTo
  • sbi - shouldBeAnInstanceOf
  • sbl - shouldBeLike
  • se - shouldEqual
  • shbc - shouldHaveBeenCalled
  • sht - shouldHaveType
  • si - shouldImplement
  • snb - shouldNotBe
  • snbc - shouldNotBeCalled
  • snbet - shouldNotBeEqualTo
  • snbi - shouldNotBeInstanceOf
  • snbl - shouldNotBeLike
  • sne - shouldNotEqual
  • snhbc - shouldNotHaveBeenCalled
  • snr - shouldNotReturn
  • sr - shouldReturn
  • st - shouldThrow
  • wr - willReturn
  • wt - willThrow

Download & Installation

Download PhpSpec Live Templates

After downloading templates go to PhpStorm import setting dialog (File -> Import Settings), choose downloaded .jar file, import it and restart IDE.

Now you are all set to develop even faster ;)

If you have any questions or suggestions how to improve templates I'm happy to hear from you!


Rommsen noticed that two abbreviations - shbc and snhbc were missing - thanks for this!

Settings were updated and uploaded with two templates mentioned above!