Skip to content

Conversation

@clue
Copy link
Owner

@clue clue commented Feb 15, 2022

This changeset adds support for running from PHARs without a file extension. This is particularly common when installing PHARs as system binaries on Unix-like platforms.

While the phar:// stream wrapper is wonderful, PHP exhibits some (afaict undocumented) behavior when it comes to PHARs with no file extension. I've written a more in-depth explanation on Twitter (https://twitter.com/another_clue/status/1493175007484301317), but the gist is that we can avoid this shortcoming by using an alias for the PHAR by first loading it. This now works out of the box without any special configuration by running the SQLite worker like this internally:

- $ php -r 'require("phar:///home/alice/Desktop/acme.phar/vendor/clue/reactphp-sqlite/res/sqlite-worker.php");'
+ $ php -r 'Phar::loadPhar("/home/alice/Desktop/acme.phar");require("phar:///home/alice/Desktop/acme.phar/vendor/clue/reactphp-sqlite/res/sqlite-worker.php");'

The updated test suite confirms this works across all supported platforms, including Windows (which requires some special care via #60).

Builds on top of #60 and #55. Together with the referenced tickets and the upstream fixes required to get this in, you're looking at several days worth of debugging and toying around with different approaches to distill this to this minimal fix that works across all supported platforms. The underlying behavior is mostly undocumented in PHP afaict, so I'm quite happy with the resulting changeset.
Refs #5 for the underlying feature request.

@SimonFrings SimonFrings merged commit bfe1a5d into clue:main Feb 15, 2022
@clue clue deleted the pharrr branch February 15, 2022 07:58
@clue clue mentioned this pull request Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants