Skip to content

Commit a80085b

Browse files
authored
Update the PHAR usages (#266)
- Remove the PHAR built-in signing for PHP-Scoper - Add the release date to the PHAR version - Add install instructions for Phive
1 parent c800372 commit a80085b

File tree

6 files changed

+62
-22
lines changed

6 files changed

+62
-22
lines changed

.travis.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ before_install:
2020
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
2121
- phpenv config-rm xdebug.ini || true
2222
- export COMPOSER_ROOT_VERSION=0.10.99
23-
- |
24-
if [ 'false' == "$TRAVIS_PULL_REQUEST" ]; then
25-
cp box.json.dist box.json
26-
openssl aes-256-cbc -K $encrypted_22e6e244c213_key -iv $encrypted_22e6e244c213_iv -in .travis/secrets.tar.enc -out .travis/secrets.tar -d
27-
tar xvf .travis/secrets.tar -C .travis
28-
fi;
2923

3024
install:
3125
- composer install --no-interaction --no-progress --no-suggest --prefer-dist $COMPOSER_FLAGS
@@ -45,7 +39,6 @@ deploy:
4539
secure: 0ei0gMDsask+ro2LeUOPfsi99fbo8img/cUnAjg2RTcV03ANpQ5rZwG6PNBpaPLwGRNF+AGvHl+amrnL5b0ZLAMutif3v6oZLm9M5Kq4H2g3zqcvXkmxhRDvEsUJBqf2UvFEXxF03GZIsM29v3l6H09IfO0rL2itMibfwz9o3ialzanRQCxfBe8bHTsmKMZALA6Xk3/Vhj/cQdK0hVv+D6RGzAIv5AhLU5yLYNtu2UcvXZxdLt4RPwnVflx5Jiu/zsmEM/CuGryHGpHQTfbEh3OQCA1bcEyFWtAp3Ngl8IwA4S/7RLb3ukYhnoKefeYy6e10DUgQvKmekc4e9n53g8Wc8p2DRbA86rcABB0pI3rrIO7tAsvsr7H970Q/Jmn3QdoH0UcnO8JptnvZzSZ5MdbIMH5fsbri5kNIw748jJngAtPi8jFb4ekmkyOL8cpC/3C/S7c/oHE9yqn/WrSNEq181iIP2eYapOA/mWrk+Hysk/O1QH10vTejcJIDjE3tWR+XtuxQrxzfD5M1Vg+pr/G6BDNEom2h6/oKdi1sUwO0XKBpmIgiFTsp9EZA3O9fjoYmcFECc5HFrMtzYf79pNj6d6jggQgQa3LB4BViAsxqc9nYtj7zYsXqFxg3Y63MSsoyHkShzkTQjLKEkQ0EXVL5d8eWWplznQdAKiEDLxc=
4640
file:
4741
- bin/php-scoper.phar
48-
- bin/php-scoper.phar.pubkey
4942
skip_cleanup: true
5043
on:
5144
tags: true

Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,13 +416,10 @@ fixtures/set025/composer.lock: fixtures/set025/composer.json
416416
fixtures/set027-laravel/composer.lock: fixtures/set027-laravel/composer.json
417417
@echo fixtures/set027-laravel/composer.lock is not up to date.
418418

419-
bin/php-scoper.phar: bin/php-scoper src vendor scoper.inc.php box.json
419+
bin/php-scoper.phar: bin/php-scoper src vendor scoper.inc.php box.json.dist
420420
$(BOX) compile
421421
touch $@
422422

423-
box.json: box.json.dist
424-
cat box.json.dist | sed -E 's/\"key\": \".+\",//g' | sed -E 's/\"algorithm\": \".+\",//g' > box.json
425-
426423
COVERS_VALIDATOR=$(PHPBIN) vendor-bin/covers-validator/bin/covers-validator
427424
clover.xml: src
428425
$(COVERS_VALIDATOR)

README.md

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ potentially very difficult to debug due to dissimilar or unsupported package ver
3131

3232
- [Installation](#installation)
3333
- [Usage](#usage)
34+
- [Phive](#phive)
3435
- [PHAR](#phar)
3536
- [Composer](#composer)
3637
- [Configuration](#configuration)
@@ -67,16 +68,27 @@ potentially very difficult to debug due to dissimilar or unsupported package ver
6768
## Installation
6869

6970

71+
### Phive
72+
73+
74+
You can install Box with [Phive][phive]
75+
76+
```bash
77+
$ phive install humbug/php-scoper --force-accept-unsigned
78+
```
79+
80+
To upgrade `php-scoper` use the following command:
81+
82+
```bash
83+
$ phive update humbug/php-scoper --force-accept-unsigned
84+
```
85+
86+
7087
### PHAR
7188

7289
The preferred method of installation is to use the PHP-Scoper PHAR, which can
7390
be downloaded from the most recent [Github Release][releases].
7491

75-
As the PHAR is signed, you should also download the matching
76-
`php-scoper.phar.pubkey` to the same location. If you rename `php-scoper.phar`
77-
to `php-scoper`, you should also rename `php-scoper.phar.pubkey` to
78-
`php-scoper.pubkey`.
79-
8092

8193
### Composer
8294

@@ -764,3 +776,4 @@ now been moved under the
764776
[patchers]: #patchers
765777
[php-scoper-integration]: https://github.com/humbug/box#isolating-the-phar
766778
[phar-extract-to]: https://secure.php.net/manual/en/phar.extractto.php
779+
[phive]: https://github.com/phar-io/phive

box.json.dist

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
{
2-
"algorithm": "OPENSSL",
3-
"key": ".travis/php-scoper-private.pem",
2+
"banner": [
3+
"This file is part of the humbug/php-scoper package.",
4+
"",
5+
"Copyright (c) 2017 Théo FIDRY <theo.fidry@gmail.com>,",
6+
" Pádraic Brady <padraic.brady@gmail.com>",
7+
" Bernhard Schussek <bschussek@gmail.com>",
8+
"",
9+
"This source file is subject to the MIT license that is bundled",
10+
"with this source code in the file LICENSE."
11+
],
412

513
"files": [
614
"src/scoper.inc.php.tpl"
715
],
816
"git": "git_version_placeholder",
17+
"datetime": "release-date",
918

1019
"compression": "GZ",
1120

src/Console/Application.php

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515
namespace Humbug\PhpScoper\Console;
1616

17+
use PackageVersions\Versions;
1718
use Symfony\Component\Console\Application as SymfonyApplication;
19+
use function trim;
1820

1921
final class Application extends SymfonyApplication
2022
{
@@ -30,15 +32,38 @@ final class Application extends SymfonyApplication
3032

3133
ASCII;
3234

35+
private $releaseDate;
36+
37+
/**
38+
* {@inheritdoc}
39+
*/
40+
public function __construct(string $name = 'Box', string $version = null, string $releaseDate = '@release-date@')
41+
{
42+
if (null === $version) {
43+
$rawVersion = Versions::getVersion('humbug/php-scoper');
44+
45+
[$prettyVersion, $commitHash] = explode('@', $rawVersion);
46+
47+
$version = $prettyVersion.'@'.substr($commitHash, 0, 7);
48+
}
49+
50+
$this->releaseDate = false === strpos($releaseDate, '@') ? $releaseDate : '';
51+
52+
parent::__construct($name, $version);
53+
}
54+
3355
/**
3456
* @inheritdoc
3557
*/
3658
public function getLongVersion(): string
3759
{
38-
return sprintf(
39-
'<info>%s</info> version <comment>%s</comment>',
40-
$this->getName(),
41-
$this->getVersion()
60+
return trim(
61+
sprintf(
62+
'<info>%s</info> version <comment>%s</comment> %s',
63+
$this->getName(),
64+
$this->getVersion(),
65+
$this->releaseDate
66+
)
4267
);
4368
}
4469

tests/Console/Command/AddPrefixCommandTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
use Symfony\Component\Filesystem\Filesystem;
2727
use function file_get_contents;
2828
use function Humbug\PhpScoper\escape_path;
29+
use function preg_replace;
2930

3031
/**
3132
* @covers \Humbug\PhpScoper\Console\Command\AddPrefixCommand
@@ -103,6 +104,7 @@ public function test_get_help_menu()
103104
EOF;
104105

105106
$actual = $this->appTester->getDisplay(true);
107+
$actual = preg_replace('/php-scoper-test version .*/', 'php-scoper-test version UNKNOWN', $actual);
106108

107109
$this->assertSame($expected, $actual);
108110
$this->assertSame(0, $this->appTester->getStatusCode());
@@ -126,6 +128,7 @@ public function test_get_version_menu()
126128
EOF;
127129

128130
$actual = $this->appTester->getDisplay(true);
131+
$actual = preg_replace('/php-scoper-test version .*/', 'php-scoper-test version UNKNOWN', $actual);
129132

130133
$this->assertSame($expected, $actual);
131134
$this->assertSame(0, $this->appTester->getStatusCode());

0 commit comments

Comments
 (0)