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:
/ ├── templates/ │ ├── template_set_1.xml │ ├── template_set_2.xml │ ├── ... │ └── template_set_N.xml └── ...
Check out a few ready-to-use repos with snippets:
- Laravel koomai/phpstorm-laravel-live-templates (⭐️964)
- Symfony, Twig knpuniversity/phpstorm-settings (⭐️123)
- WordPress gist://pronskiy/e0463181ed5bf1f08cdcccb32af87dc6 (fork ⭐️54)
- Twig pronskiy/PhpStorm-Live-Templates-Twig-Extended (fork ⭐️20)
- Magento phpstorm-magento-live-templates (⭐️4)
Share your live templates and send us a link!
We are brainstorming on how to improve the sharing experience. For example, maybe distribute live templates as Composer packages? We’d appreciate any comments and suggestions!
Please let us know what you think of this approach. Do you use live templates? What are they lacking to be perfect for you?
Subscribe to Blog updates
Thanks, we've got you!
Qodana Clone Finder: Early Access Program
In December 2020, we announced the EAP for Qodana, which is rapidly evolving into a comprehensive platform that allows companies to perform multi-level evaluations of the quality of code they own, contract, or purchase. Qodana helps you detect bugs without relying on an IDE, either on a local machi…
PhpStorm 2020.2 EAP #3
The Early Access Program for PhpStorm 2020.2 is in full swing and today we’ve got the third build of the 2020.2 EAP for you. In this blog post, you can read about improvements for Git installed in WSL2 and Search Everywhere. Download PhpStorm 2020.2 EAP (more…)…
PhpStorm 2019.3.3 Preview
We’ve just rolled out a preview for the third minor update for PhpStorm 2019.3. Please give the PhpStorm 2019.3.3 Preview build 193.6494.5 a try and share your feedback with us. (more…)…
How to Upgrade to PHP 7.4 with PhpStorm
Check out our fresh video with a few nice tips and tricks on how to update your codebase to PHP 7.4. It combines materials from the PhpStorm 2019.2 and PhpStorm 2019.3 releases, with a few cool bonuses to boot. Nikita drew our attention to the fact that setters are slower than assigning prop…