1

I generated new .env file with copy .env.example .env command in PhpStorm terminal. Then created .env file then but I can't edit in PhpStorm. When I double clicked it's open external editor (Notepad++).

unvariable file type

miken32
  • 42,008
  • 16
  • 111
  • 154
Kvlknctk
  • 634
  • 12
  • 27

3 Answers3

16
  1. Settings/Preferences | Editor | File Types
  2. Find Files Opened in Associated Application entry in the top list
  3. Remove associated entry for .env files from the bottom list (Registered Patterns).
  4. Re-associate such pattern with another (more appropriate) File Type (e.g. "Text Files" .. or whatever other format that would be)

P.S. There is .​env files support plugin that adds file icon & syntax coloring for .env files and code completion helper in certain languages (PHP in particular):

https://plugins.jetbrains.com/plugin/9525--env-files-support

Features:

  • Environment variables completion based on .env, Dockerfile and docker-compose.yml files.
  • Go to declaration (in .env file) and usages(in code), by Ctrl / Cmd + Click or hot key (Ctrl / Cmd + B, etc.)
  • .env file syntax highlighter

UPDATE: 2022-01-13

For the modern IDE versions (v2020.3.x and newer) check the following StackOverflow answer. The IDE now has more options that can affect the way how IDE treats specific file: https://stackoverflow.com/a/65701638/783119

LazyOne
  • 158,824
  • 45
  • 388
  • 391
1

There is a plugin for .env files. It also helps by autocompleting env() and getenv() functions. https://plugins.jetbrains.com/plugin/9525--env-files-support

Adelf
  • 706
  • 4
  • 12
1

Go to file -> settings -> Editor -> File Types -> Recognized file types and select the "Text" -> add some patterns

.evn
*.env
.evn.*
*.env.*
Najathi
  • 2,529
  • 24
  • 23