Jump to content

ProcessWire Live Templates (aka snippets) for IntelliJ IDEs (like PHPStorm)


dotnetic
 Share

Recommended Posts

Coming to an IntelliJ IDE (like PHPStorm) near you soon.

Live Templates or snippets provide a short way to write repeating code. You enter an abbrevitation and the editor completes the code for you.

Here is one example when I want to setup a new module:

 

@bernhard Has snippets for VSCode in his great RockMigrations module also, be sure to check them out, if you use VSCode.

As I use RockMigrations in every PW installation I also add snippets for migrations:

 

 

  • Like 9
Link to comment
Share on other sites

17 minutes ago, bernhard said:

How does this work? Can you reuse my snippets?

Just the ProcessWire Code, I have to transform everything manually. Sadly IntelliJ has a weird format for the live templates which are stored in an XML file. Sharing and importing isn't also as easy as copying the files to the root directory. Instead you have to import them as settings for the IDE and restart the IDE afterwards.

21 minutes ago, bernhard said:

How does this work?

Live templates are a native function of PHPStorm, I think they were a thing before they existed in VSCode. It is somewhat similar to snippets in VSCode. You have your code and then enter $myvariable$ for inserting user text, or things like $boolean$ or $enum$ and can define values for that.

  • Like 1
Link to comment
Share on other sites

  • 3 weeks later...
6 hours ago, gs-df said:

Any updates @dotnetic? Can't wait... ?

You can import the attached file into your IDE. See instructions here https://www.jetbrains.com/help/phpstorm/sharing-your-ide-settings.html#import-settings-from-a-zip-archive

I don't have much time atm and so I can not provide full instructions and the file not in a repo.

Please note, that if you use settings sync, the import will not work and you have to put the "template" folder of the zip file into your PHPStorm settings folder which is depending on your OS somewhat like C:\Users\username\AppData\Roaming\JetBrains\PhpStorm2022.2 (Windows)

image.png.3d6dd1578eb5affa95a97080b8669d82.png paste it here!

settings.zip

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...