phive icon indicating copy to clipboard operation
phive copied to clipboard

Add extension .phar to installed tools

Open Aeliot-Tm opened this issue 1 year ago • 10 comments

PHPStorm don't understand content of PHAR file and cannot autocomplete when tool installed via link and without extension. Currently, we have to do it manually. So, this update should help to solve this issue.

image

Aeliot-Tm avatar Oct 27 '24 16:10 Aeliot-Tm

It's actually very much intentional we drop the extension. And one of the reaons is exactly that PHPStorm does NOT "see" them. Because you exactly do NOT want to have autocomplete for code that just happens to be used by your tools.

I see that there is at least one valid edge case: PHPUnit, which happens to be a tool as well as a framework for which you'd want autocomplete when writing tests. But then again, you do NOT want auto complete for all of PHPUnit but only the relevant framework components.

Thanks for providing this PR though anyway. I have to think about this change. It feels like the wrong solution to the problem.

theseer avatar Oct 27 '24 22:10 theseer

On my point of view, it is useful not only for PHPUnit, but for all scripts which works with configs in php-files.

Aeliot-Tm avatar Oct 28 '24 16:10 Aeliot-Tm

I'm still not fully convinced but am considering to add this, as you made it a configurable thing.

Did you test this on windows? Because adding .phar to a .bat file is not going to work ;)

theseer avatar Nov 22 '24 08:11 theseer

Second question: Is the -e-Handling reflected in the data stored in the phive.xml / .phive/phars.xml respectively?

theseer avatar Nov 22 '24 08:11 theseer

This config affects only new installs case all aspects of installation of packages added before handled by .phive/phars.xml

Aeliot-Tm avatar Nov 22 '24 08:11 Aeliot-Tm

I don't quite understand why you talk about .bat files case phive should install entire phar version of scripts. Could you clarify what I am missing?

Aeliot-Tm avatar Nov 22 '24 08:11 Aeliot-Tm

On a unix'ish OS, we use symlinks per default to map a shared phar from the location we store them into the respective project. We can, of course, easily control the target name in the project as your patch suggests.

On Windows, a .phar is not executable as windows does not have the concept of executable attributes. Thus, for windows, we deploy a .bat-file as a wrapper. (See https://github.com/phar-io/phive/blob/master/src/services/phar/WindowsPharInstaller.php and https://github.com/phar-io/phive/blob/master/conf/pharBat.template, respectively).

Your implementation seems to be unaware of this and thus would potentially only work when the phar is copied along, e.g. wenn --copy is specified.

And I'm not sure if the changed name is reflected in the phive.xml / .phive/phars.xml file when -e was used, given the location you apply the configuration option. But I haven't looked into that.

theseer avatar Nov 22 '24 08:11 theseer

Thank you, @theseer. Let me check and make necessary updates.

Aeliot-Tm avatar Apr 06 '25 19:04 Aeliot-Tm

Thank you @Aeliot-Tm : the configuration would help not only with PHPUnit but also for php-cs-fixer :)

The solution I currently apply is:

  1. install the tool
  2. alter phive.xml to have the .phar extension for that tool
  3. run again phive install (which will copy the tool with the expected .phar extension)
  4. remove the tool installed in step 1

note: I use --copy and I work on Linux

thePanz avatar Apr 17 '25 09:04 thePanz

https://github.com/phar-io/phive/issues/116 https://github.com/phar-io/phive/issues/405

MacDada avatar Jul 21 '25 16:07 MacDada