-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ".phar" extension to symlink files #116
Comments
Can confirm this. Maybe an additional flag "--with-suffix" would solve this problem. |
I agree that to be annoying. Instead of only controlling the potential extension though, I'd prefer to have a switch to override the complete filename of the destination file. We already have Sidenote: This has nothing to do with symlinks. PHPStorm as of 2017.2.4 does not handle files without an extension very well, regardless of being a symlink or not. Funny enough, if the phar is symlinked it at least is detected as PHP while a copy of the same file is just an unknown file. Sidenote 2: I consider that a bug in PHPStorm rather than an issue of phive. But until Jetbrains decides to fix that in PHPStorm, phive probably needs to offer a workaround. |
PHPUnit expects its plugins to have a .phar extension as well. But for compatibility the tools should be callable by name (without extension). I suggest using a combination of the two approaches:
The tool.phar would be available for PHPStorm and PHPUnit, while the shell script allows to call |
We already considered simply creating two links or have the suggested shell wrapper, but decided against doing in the proposed way. Let me elaborate that a little: Phive is currently lacking support for anything but "application" type phars (as per manifest) - meaning we don't yet make use of the information provided by the manifest. The plan is to add support for the other types and have extensions as well as libraries keep the .phar extension and also install them in dedicated directories. That way, the tools directory can be ignored from the IDE while phars in the the library and extension directories can still be included. Regaring PHPUnit: We're currently considering to extend the manifest definition to allow something like a multi-type archive, say application and library, which would then cause Phive to create two links, one without extension in tools and one with extension in library - or whatever folder name we decide as the default. Or, pending a discussion with @sebastianbergmann, we might add a new stub type and have a PHPUnit-stub-phar that is logically linked to the application type phar. The idea here obviously is to have only the stubs for the IDE in the stub-phar and to only include the stubs for the "public" API of PHPUnit and accompanying classes. That way, code that is internal to PHPUnit or would otherwise be potentially duplicated (like say symfony libs) will not show up as duplicate in PHP Storm. |
Handling the extension phars for a tool in a separate way would be the best solution. I am playing around with hardlinks for the phars at the moment, trying to solve the PHPStorm issue on Windows. |
That looks interesting :) |
I opened a merge request for it. However it might make sense to move some logic as options into the
PharActivator::FORCE_COPY - copy the phar to the destination, not just link it. A standard tool just needs to be available as That seems to be difficult to implement OS independent. |
I think it is better to have the default approach as it is now (no extensio) as it is a pretty common convention for linux/mac environments but provide 2 flags possibly:
The second one is more or less IMO a convenience one, to not force the full name of a package (useful with long ones) |
Maybe not a flag, but an configuration option. Phive does not have that, so that would be a bigger change. Between two contributors of a project one could have Phive configured to provide local Phars for IDE integration and the other not. |
Imho, there is literally no point in having a tool's classes show up in an IDE. Rather to the contrary: it's highly annoying if that happens and getting rid of these was one of the reasons to start For the aforementioned reasons and conceptual ideas, I'm against adding a switch that adds an extension to the tool filename. I also fail to see the point of adding a configuration option? What would be the benefit? |
I was not speaking about code completion, but IDE integration. PHPStorm has plugins that integrate the tools, so that you can use them via GUI and internal functions. Currently Phive allows to reference the execute the tools using an predefined stable comment, independent from the version - but only via console command. But to use them from the PHPStorm you have to configure something like: That is why I modified Phive to provide me with local Phars. I exclude them from the code completion, but I get a stable filename for the IDE settings. The setup for the tools gets a lot easier and profits from version management. It makes my live a lot easier. |
Maybe it's too warm, but I don't get it. Why would you even consider to reference anything the local storage path? That's phive's internal domain and should be an implementation detail. With |
Maybe this is only needed on Windows. I don't get a local symlink. On windows the |
Why can't windows just be a useful OS? Okay, I keep forgetting that windows is incapable of properly handling symlinks and still relies on file extensions. But then, why would the IDE have issues with running a tool that way? You don't tell me the plugin actually checks the content of the file you point it to or its extension? |
The file, PHPStorm seems to validate the file and extract the version. |
Putting the *.phar files into the tools directory has the downside that an IDE might recognize it as part of the project code. But it will allow for IDE integration on Windows and code completion for unit tests. The best solution for PHPUnit would be a special Phar that contains the public API. But this sounds complex and a lot of work in Phive and PHPUnit. It will take time. Even it that is solved here would still be the problem of IDE integration on Windows (Well, it would be possible to use a different file extension). That is why I suggest moving the decision to the user for now. With a global option / command argument in Phive the individual user could decide if he/she wants locally linked Phars. |
Unfortunately PHPStorm is not able to work out if a symlink is spotting to a phar file.
In my case this removes the autocomplete feature for unit tests, since PHPStorm doesn't know about PHPUnit at all, although the phar file symlink is under the project root.
To fix this behavior I have to add the ".phar" extension in the phive.xml manually.
How about to add the extension by default or at least with a global config paramter?
The text was updated successfully, but these errors were encountered: