Tutorials

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.

php-templates

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

image description