Skip to content

Commit

Permalink
Merge pull request #61 from clue-labs/pharrr
Browse files Browse the repository at this point in the history
Support spawning worker process from within PHARs without file extension
  • Loading branch information
SimonFrings authored Feb 15, 2022
2 parents cfd0cd4 + ef4cb2e commit bfe1a5d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ jobs:
if: ${{ matrix.php < 7.3 }}
- run: cd tests/install-as-dep && composer install && php query.php
- run: cd tests/install-as-dep && php -d phar.readonly=0 vendor/bin/phar-composer build . query.phar && php query.phar
- run: cd tests/install-as-dep && mv query.phar query.ext && php query.ext
- run: cd tests/install-as-dep && mv query.ext query && php query
8 changes: 4 additions & 4 deletions src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ private function openProcessIo($filename, $flags = null)
$cwd = null;
$worker = \dirname(__DIR__) . '/res/sqlite-worker.php';

if (\class_exists('Phar', false) && \Phar::running(false) !== '') {
$worker = '-r' . 'require(' . \var_export($worker, true) . ');'; // @codeCoverageIgnore
if (\class_exists('Phar', false) && ($phar = \Phar::running(false)) !== '') {
$worker = '-r' . 'Phar::loadPhar(' . var_export($phar, true) . ');require(' . \var_export($worker, true) . ');'; // @codeCoverageIgnore
} else {
$cwd = __DIR__ . '/../res';
$worker = \basename($worker);
Expand Down Expand Up @@ -297,8 +297,8 @@ private function openSocketIo($filename, $flags = null)
$cwd = null;
$worker = \dirname(__DIR__) . '/res/sqlite-worker.php';

if (\class_exists('Phar', false) && \Phar::running(false) !== '') {
$worker = '-r' . 'require(' . \var_export($worker, true) . ');'; // @codeCoverageIgnore
if (\class_exists('Phar', false) && ($phar = \Phar::running(false)) !== '') {
$worker = '-r' . 'Phar::loadPhar(' . var_export($phar, true) . ');require(' . \var_export($worker, true) . ');'; // @codeCoverageIgnore
} else {
$cwd = __DIR__ . '/../res';
$worker = \basename($worker);
Expand Down
2 changes: 2 additions & 0 deletions tests/install-as-dep/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/composer.lock
/query
/query.ext
/query.phar
/vendor/

0 comments on commit bfe1a5d

Please sign in to comment.