Setting up Prettier on PhpStorm 2019.1.3 - phpstorm

I have Prettier enabled in the plugins. The question is simply, where are these settings? Folder permissions or what? The picture where they are showing is from the intellij-support website. The picture with the question mark is with the settings on my PhpStorm

A possibility to run Prettier on Save has been introduced in PhpStorm 2020.1; if upgrading the IDE is not an option for you, I can only suggest setting it up as a file watcher in in Preferences | Tools | File Watchers and make sure that Auto-save edited files to trigger the watcher (https://www.jetbrains.com/help/webstorm/2019.1/using-file-watchers.html?section=Windows%20or%20Linux#ws_filewatcher_advanced_options) is disabled

So, basically, if you want to use Prettier with PhpStorm 2019.1.3 you need to install it with npm like this jetbrains.com/help/webstorm/2019.1/prettier.html and setup the configuration of it in the package.json under "prettier" key. Then you have to right-click on the file and select "Reformat with prettier". Maybe you can set hotkey for Prettier somewhere, the default ones do not work for me for some reason. If you want your code to be automatically formatted on save you need to install this plugin: https://plugins.jetbrains.com/plugin/7642-save-actions/versions "Save Actions". I installed 2.2.0 because it has support for 2018+.Then - because I couldn't find the place where you can change default formatting tool to "Prettier" you can setup the configuration under Settings->Editor->Code Style->choose the language you desire and then configure it. Could not find a way to setup prettier without json config or after setting it up to make it work on "Save" action. Answering this just because it might help somebody somewhere.

Related

Pycharm (Jetbrains): Disable non-project files access dialog

This window pops up everytime I run pycharm and try to edit something (auto-loading the default project):
https://www.jetbrains.com/help/idea/2016.1/non-project-files-access-dialog.html?origin=old_help
How do I disable it?
Just remove the .idea folder and reopen your project. It worked for me.
I had a similar problem with Phpstorm (also built by Jetbrains).
To fix, search plugin repositories inside your IDE for 'Non Project Files Unlocker' (In Phpstorm you go to Settings->plugins->browse repositories). Install it, and that popup will never show again!

PhpStorm: how to use project root variable or relative path in PhpUnit configuration?

I would like to setup PhpUnit in PhpStorm. I press 1. Edit Configurations... and would like to enter this parameter in field 2.
I am using phpunit.xml as configuration file and all want to use a relative path like:
phpunit.xml
or use project root variable like
$PROJECT_ROOT/phpunit.xml
But both options are not working for me.
Based on your screenshot (the place where you want to use it): use full path -- in project settings such path is stored relative to the project root anyway (unless you specify some file which is outside of the project, of course) and the full path then reconstructed when needed (e.g. when shown to you or when used as a parameter during tests execution).
I don't think you'll be able to achieve what you want via the project's Run/Debug configurations. What might help you is the Default configuration file setting in your default project settings, which can be used to define the PHPUnit configuration file to use by default, so you don't need to specify it via the Use alternative configuration file option in your Run/Debug configuration.
To set this, open your Default Settings window, then navigate to Languages & Frameworks -> PHP -> PHPUnit. In the Test Runner section tick the Default configuration file checkbox and specify the location where you keep your configuration file. If this file will always be in the same path relative to your project root, you can use the $PROJECT_DIR$ variable to define the project root. So if your PHPUnit configuration file is always in the root of your project, you might set this to something like $PROJECT_DIR$/phpunit.xml. When you create a new project, its Default configuration file variable will be set to the file offset from your project root, and you won't need to use the Use alternative configuration file option in your Run/Debug configuration.
If you're opening the same project in different locations on the same machine this should work for new projects without any problem, if you want to share this configuration across machines, you might need to try PHPStorm's Exporting and Importing Settings functionality.
I'm not sure if this directly solves your problem, and it's a few months late anyway, but maybe this will be useful for someone else who stumbles across this question... The above instructions were correct for my 8.0.3 installation on Linux.

Saving in SFTP like its a normal folder

So I was using sublime-text 2 to modify some php files held on a remote server. I used nautilus sftp://... address to server to open up the folder then clicked on the files and pressed open with sublime text. Whenever I did this it automatically saved the changes on the server. For various annoying reasons I had to restore the machine to factory settings. Now whenever I try to open up the files in the way I use to be able to it just opens a blank file titled sftp in my /user/dev directory. Is there anything I need to do to get it back to the way it used to be?
Not sure anyone else has ever experienced this behavior but I never replicated the nautilus effect that I had originally. The best alternative I found was sublime sftp.
Installed by sublime package control:
https://sublime.wbond.net/installation
Then install sublime sftp:
http://wbond.net/sublime_packages/sftp
I was a student coding in php for a class so I was only using it temporarily and never paid for the license. Probably should do that if you are gonna be using it long term.

How to disable version control in phpstorm?

I am playing around with phpstorm and somehow I activated version control. I don't need it. Now all my tabs are different: orange text on gray background. All files in the file view are orange. How do I disable version control?
Go to Settings -> Version Control and remove the folder from which you would like to remove version control tracking (coloring tabs etc.) It will naturally not remove version control from your project (as in deleting the .git/ folder for instance).
The ultimate way is to disable all version control plugins (under Settings -> Plugins): CVS Integration, Git Integration, GitHub, hg4idea, Perforce Integration, Subversion Integration. After restarting PhpStorm Settings -> Version Control tab will be gone.
Note that this will disable version control for all of your projects.
You can just remove vcs.xml from .idea folder and then restart PhpStorm
In phpStorm 2022.1.3+, go to
Preferences > Version Control > Directory Mappings
Then remove the directories you don't want to watch, as Greg suggested.
Go to Settings -> Version Control and remove the folder from which you would liek to remove version control.
I have not enough reputation to +1 Greg's answer or comment, but... for those who are interrested : the same goes for Webstorm.
I had this problem and I used from 2 of notes in these answers in these page together.
As Greg has mentioned in one of replies, your git repository is in .git sub directory inside directory that you want to manage it with version control system. When you define a git repository, PhpStorm automatically generate it and with creating this sub directory, it adds a file for handling mapping between itself and version control system. It calls vcs.xml and it's located in .idea sub directory.
It's not enough to remove only .git directory. When you remove .git, you will get an error in PhpStorm every time that you open your project due to not matching vcs.xml for mapping between PhpStorm and git repository of your project. So after removing .git directory, you must also remove vcs.xml files from .idea and now you won't have any error or warning in your PhpStorm.
It doesn't need to restart PhpStorm at all and after this, colors of all of files that was mentioned in questions return to normal colors in PhpStorm.

Intellij 11.0.1 seems to be ignoring my .hgignore file

I have the following .hgignore file that should keep Intellij's constantly changing internal config files from polluting our source control.
syntax: glob
.idea/*
target/*
logs/*
out/*
myapp.iml
myapp-web.iml
Tortoise and the command line seem to respect the fact that files like ".idea/dataSources.xml" are not meant to be added to source control but intellij's hg4idea are constantly asking if I would like to add files like ".idea/dataSources.xml" to source control.
Is my .hgignore file just wrong or is there a bug in Intellij?
It's a known bug, please vote. As a workaround you can ignore files in Settings | Version Control | Ignored Files.
To add files to the IntelliJ ignore list go to:
Settings
Version Control
Ignored Files