Sharing Code Snippets in PhpStorm Easy Way

Code snippets, or Live Templates as they are called in PhpStorm, can help you save and reuse code. This can be any code fragment that you find yourself using often – just a single line of code like a method definition, or a hundred lines skeleton for a whole feature.

Many code snippets, such as Project-specific snippets, Framework snippets, or Library snippets, can be useful for your team and even the entire community. PhpStorm allows you to share snippets via GitHub repositories!

Some of our users already shared code snippets and provided instructions on how to install them by copying files manually. But there is a much simpler way to obtain shared snippets: You can do it by adding a read-only settings repository:

Go to Preferences (Settings) | Tools | Settings Repository

Add a read-only source with a link to GitHub repository

Restart PhpStorm

In fact, this way you can share not only live templates, but other IDE settings too. Read more about all shareable parts here. The settings repository that you plan to share must contain the templates folder with Live Templates XML files inside: