How to escape quotes in PHP Storm while building argument list for an external tool

I am trying to use PHP CS Fixer to format somethings in my code

 

I pulled it in using composer and then went to Preferences -> Tools -> External Tools -> + sign

 

Program: /Users/rohan0793/.composer/vendor/bin/php-cs-fixer

Arguments: fix --rules='{"ordered_imports": {"sort_algorithm":"length"}}' $FileDir$/$FileName$

Working directory: $ProjectFileDir$

 

Now when I am running this, it runs a command like so:

 

/Users/rohan0793/.composer/vendor/bin/php-cs-fixer fix --rules='{ordered_imports: {sort_algorithm:length}}' /Users/rohan0793/Code/learning-mix/app/Http/Controllers/Auth/RegisterController.php

 

I was getting some weird error, so I decided to take that whole command and run it in the terminal manually and I say a invalid JSON error, which made sense because the quotes were stripped off. So, how do tell the IDE to not strip the quotes away, I tried using back slashes, but no luck

 

Edit: I found this https://youtrack.jetbrains.net/issue/WI-8228 and it says fixed but I still have the problem

1 comment

Hi there,

You can always use this workaround: create a shell/batch script that would do the job (call the actual program) and use it instead.

Program: /path/to/my-specail-php-cs-fixer

Arguments: $FileDir$/$FileName$

Working directory: $ProjectFileDir$

 

Then your my-specail-php-cs-fixer will take the file name parameter and execute the actual command.

Not ideal (not that flexible as you need to create separate executable file) but works for sure.

 

Also, have a look at https://youtrack.jetbrains.com/issue/IDEA-13322#focus=streamItem-27-148590-0-0 -- try using "\" when you need a single "

1

Please sign in to leave a comment.