Skip to content

Commit

Permalink
Fix phar run
Browse files Browse the repository at this point in the history
  • Loading branch information
maartendekeizer committed Oct 21, 2023
1 parent b0a8976 commit 09d600d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
name: Build PHAR
name: Build PHAR and publish

on:
push:
branches: [ "main" ]
release:
types: [ created ]

permissions:
contents: read
contents: write

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
Expand All @@ -23,43 +22,42 @@ jobs:
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Download Box
run: wget https://github.com/box-project/box/releases/download/4.4.0/box.phar

- name: Set phar.readonly=0
run: sudo sh -c 'echo "phar.readonly=0" > /etc/php/8.1/cli/conf.d/99-phar.ini'

### Debug

- name: "Debug: show system env vars"
run: export

- name: Run phpinfo
run: php -i

### Prepare for boxing

- name: Install dependencies
run: composer install --prefer-dist --no-progress

- name: Dump system envs to PHP via composer
- name: Dump envs via composer
run: composer dump-env prod

- name: Remove dev cache
run: rm -Rf var/cache/dev
- name: Cache warmup
run: php new-bin/console cache:warmup

### Box it

- name: Run Box
env:
# see https://github.com/box-project/box/issues/988
BOX_ALLOW_XDEBUG: '1'
run: php box.phar compile -v

### Post boxing actions

run: php box.phar compile
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: kopio.phar
path: build/kopio.phar
upload_release:
runs-on: ubuntu-latest
needs:
- build
if: github.event_name == 'release'
steps:
- name: Download artifact from build step
uses: actions/download-artifact@v3
with:
name: kopio.phar
path: .
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
kopio.phar
23 changes: 1 addition & 22 deletions autoload_runtime.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,7 @@ if (true === (require_once __DIR__.'/autoload.php') || null === $scriptFileName
return;
}

////// fix for missing Phar class
echo 'Loaded INI file: ' . php_ini_loaded_file() . PHP_EOL;
echo 'Scanned INI files: ' . php_ini_scanned_files() . PHP_EOL;
echo 'ENV dump: ' . PHP_EOL;
print_r($_ENV);
print_r(getenv());
$pharPath = '';
if (class_exists('Phar', false)) {
$pharPath = Phar::running();
} else {
echo 'Phar class not found, declared classes:' . PHP_EOL;
print_r(get_declared_classes());
echo 'PHP version:' . PHP_EOL;
print_r(phpversion());
echo 'Loaded extension:' . PHP_EOL;
print_r(get_loaded_extensions());
}
////// end

////// dump info about paths
var_dump($pharPath, $scriptFileName);
////// end
$pharPath = Phar::running();

if (strlen($pharPath) > 0 && !str_starts_with($scriptFileName, 'phar://')) {
$scriptFileName = $pharPath.DIRECTORY_SEPARATOR.$scriptFileName;
Expand Down
2 changes: 2 additions & 0 deletions new-bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;

$_SERVER['APP_SCRIPT_FILENAME'] = __FILE__;

if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
}
Expand Down

0 comments on commit 09d600d

Please sign in to comment.