php-parallel-lint/PHP-Parallel-Lint

Building phar is not possible

cavo789 opened this issue · 10 comments

Hello

I'm trying to build the .phar file version and I'm thus following the guide as described in your README.md file (https://github.com/php-parallel-lint/PHP-Parallel-Lint#create-phar-package)

php box.phar build
Building...

[RuntimeException]
failed to get contents of 'C:\temp\PHP-Parallel-Lint\parallel-lint.php'

build [-c|--configuration="..."]
  • The box.json file mention parallel-lint.php for the main key while the file didn't have the .php extension. So, I edit the file and remove the .php extension. I've thus "main": "parallel-lint", in box.json
  • I run php box.phar build once more and now building is correct.

But, now, running php parallel-lint.phar throw an error:

PHP Fatal error:  Cannot declare class ComposerAutoloaderInit8d3d5124130cbc6652f1aad8a66cf923, because the name is already in use in phar://C:/temp/PHP-Parallel-Lint/parallel-lint.phar/vendor/composer/autoload_real.php on line 5

Can you take a look please ?

Note: I've also tried https://github.com/box-project/box for creating the phar but here too, it doesn't work.

jrfnl commented

@grogy Would it be an idea to do a test build of the phar in the CI run and let it upload the resulting file as an artifact ? Especially easy to do once switched to GH Actions instead of Travis.

The phar from a CI run on a tag could then be added to the tag and if people want to use the phar to test PRs and such, all they'd need to do would be to get the artifact from that build.

grogy commented

@jrfnl original idea, thank you. The result can look like assets on https://github.com/vrana/adminer/releases ?

@cavo789 I managed to get it to work by adding a break; into parallel-lint after the line:

$loaded = true;

Then I saw the MR #39 which effectively does the same. The last version of Box I managed to build this with was with 3.5.0 using PHP7.3

Hi

That's a great news! I'm waiting for the phar to add PHP-Parallel-Lint in my GitLab CI.

I can confirm, I can create the phar too after having modified two files:

diff --git a/box.json b/box.json
index 951802d..8c6fc81 100644
--- a/box.json
+++ b/box.json
@@ -5,7 +5,7 @@
         "Herrera\\Box\\Compactor\\Php"
     ],
     "extract": false,
-    "main": "parallel-lint.php",
+    "main": "parallel-lint",
     "files": [
         "LICENSE"
     ],
diff --git a/parallel-lint b/parallel-lint
index 0d77fdb..6c1a2bf 100755
--- a/parallel-lint
+++ b/parallel-lint
@@ -49,6 +49,7 @@ foreach ($autoloadLocations as $autoload) {
     if (is_file($autoload)) {
         require_once($autoload);
         $loaded = true;
+        break;
     }
 }

box.json needs to be modified and parallel-lint too, like you mention it.

@cavo789 One thing spotted doesnt work is the colors, may be related to #40

Appears to fail the class_exists check on

if (class_exists('\JakubOnderka\PhpConsoleColor\ConsoleColor')) {

not sure how to get around that yet

jrfnl commented

@grogy I think this issue can be closed now PR #46 has been merged as it includes automatically generating a phar on each build.

The master branch seems to be able to produce a phar file consistently, so yeah. Maybe creating a release with the updated code (and letting the actions generate the phar and add it) would be even better.

grogy commented

Is released new version 1.3.0 and is created PHAR https://github.com/php-parallel-lint/PHP-Parallel-Lint/releases/tag/v1.3.0

This issue can be closed right?

grogy commented

Yes, I close it as resolved. Thank you