Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save malteschlueter/0916c1bc128c75d452181529b008f2c9 to your computer and use it in GitHub Desktop.
Save malteschlueter/0916c1bc128c75d452181529b008f2c9 to your computer and use it in GitHub Desktop.
IntelliJ (i.e. PhpStorm): Generate random UUIDs without plugins

IntelliJ (i.e. PhpStorm): Generate random UUIDs without plugins

You can generate random UUIDs without plugins in PhpStorm or other IntelliJ applications.

  1. Open PhpStorm Settings
  2. Go to Editor > Live Templates
  3. Expand the PHP section
  4. Click on the Add button, + on the right side, and select Live template
  5. In the abbreviation field, enter uuid. This is what we'll type to expand the template
  6. In the template text field, enter $VALUE$
  7. Click Edit variables
  8. In the line for the variable named VALUE, add the expression groovyScript("UUID.randomUUID().toString()") and select Skip if defined
  9. Click Define below the ⚠️ No applicable contexts
  10. Select the desired options where you want to generate UUIDs, i.e.
    • For strings in PHP PHP > String literal
    • For strings in JSON JSON > JSON string literal
  11. Save and close the settings with the Ok button
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment