Updating Your Templates in PhpStorm

In the recent What’s New video for PhpStorm 2016.3, I noticed I was always adding PHP 7’s strict type declaration declare(strict_types=1) to every new file I created.

I commented at the time that I should update my default templates to include this by default and was asked at the time how to do that. I said I’d record a video, but I’ve realised it’s such a simple task that this blog post covers it.

So, to update your default templates, open your settings pane and navigate to Editor then File and Code Templates and in my case PHP File, PHP Class, PHP Interface, PHP Trait and PHP Unit Test. You can then update the new file template in the right-hand pane — I’m adding the declaration for strict types.


If you want to edit anything that’s included, you can use the Includes tab — the Code tab has the templates that are used when you use code generation, when you create Getters and Setters for example.

I hope this helps, sorry for the delay!

 – Gary and the PhpStorm Team

About Gary Hockin

Gary Hockin has been creating code to power web applications for 15 years, the last three of them at an extraordinary level. He is handsome, talented, funny and articulate, and also extremely modest. Gary is a valued contributor to Zend Framework 2 and is a member of the community review team. He's married and has two wonderful children, and when he's not coding, writing about code, speaking about code or reading about code, he can usually be found in the pub playing pool.
This entry was posted in PhpStorm, Tutorial and tagged , . Bookmark the permalink.