Skip to content

Commit c34a116

Browse files
committed
minor #3726 Use Box 3 to build the PHAR (theofidry, keradus)
This PR was merged into the 2.12 branch. Discussion ---------- Use Box 3 to build the PHAR This PR is a suggestion to switch from the unmaintained Box 2 to the Humbug fork in which the version 3 is being developed. A few things worth mentioning: - I used a `Makefile` instead of a bash file as I think it's an improvement for this kind of task, there is a better discoverability (type `make` and you could get the list of the commands) and it's easier to manage the task dependencies, i.e. get that `make smth` and it just works experience, no need to figure out how to install Box, do a `composer install` or something. - I used [`bamarni/composer-bin-plugin`](https://github.com/bamarni/composer-bin-plugin) to install Box as a dependencies without polluting the library dependencies. I can switch that to a PHAR if you prefer, but in any case I think it's better to have a way which does not require contributors to figure out which tool they need to install and better not require them a tool globally on their machine. If you are interested in more on the topic, I wrote an [entire article](https://medium.com/@tfidry/managing-your-dependencies-in-php-321d584441ab) about it I also noticed the `composer.lock` is not committed. IMO it should: it sure does not make any difference to the user when consuming the project as a library, but when you are shipping a PHAR you are shipping a real application on which it's better to have control on what dependencies is used there. On the same token, I didn't find any e2e tests for the PHAR. I would _highly_ recommend to have one. Updating all the deps, adding some on the fly and shipping all the stuff in the PHAR and wish that it just works is being a bit insouciant. The PHAR transformation is not a trivial process although Box try very hard to make it easier, there is still code that just don't work within the PHAR. I've pushed that against 2.x as it's still the default branch, but it can be easily ported to 3.x as well Commits ------- b25d20b Update Box 3 integration 86f03cd Upgrade to Box 3
2 parents 532877c + b25d20b commit c34a116

File tree

5 files changed

+40
-24
lines changed

5 files changed

+40
-24
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/.php_cs
2+
/box.json
23
/composer.lock
4+
/php-cs-fixer.phar
35
/phpunit.xml
46
/vendor/

box.json

Lines changed: 0 additions & 21 deletions
This file was deleted.

box.json.dist

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"check-requirements": false,
3+
"dump-autoload": false,
4+
"stub": "php-cs-fixer",
5+
"compactors": [
6+
"KevinGH\\Box\\Compactor\\Json",
7+
"KevinGH\\Box\\Compactor\\Php"
8+
],
9+
"files": [
10+
"dev-tools/ci-integration.sh",
11+
"LICENSE"
12+
],
13+
"finder": [
14+
{
15+
"name": [
16+
"*.php"
17+
],
18+
"exclude": [
19+
"Test",
20+
"test",
21+
"Tests",
22+
"tests"
23+
],
24+
"in": [
25+
"src",
26+
"vendor"
27+
]
28+
}
29+
],
30+
"blacklist": [
31+
"psalm-autoload.php"
32+
],
33+
"git-commit": "git-commit"
34+
}

dev-tools/build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ composer config platform.php 2> /dev/null || composer config platform.php 5.6.0
88
composer require --no-update symfony/polyfill-mbstring
99

1010
# install package deps without dev-deps / remove already installed dev-deps
11+
# box can ignore dev-deps, but dev-deps, when installed, may lower version of prod-deps
1112
composer update --no-interaction --no-progress --no-dev --prefer-stable
1213
composer info -D | sort
1314

14-
# install box2 globally
15-
composer global show kherge/box -q || composer global require --no-interaction --no-progress kherge/box:^2.7
15+
composer show -d dev-tools humbug/box -q || composer update -d dev-tools --no-interaction --no-progress
1616

1717
# build phar file
18-
php -d phar.readonly=false "$(composer config home)/vendor/bin/box" build
18+
dev-tools/vendor/bin/box compile
1919

2020
# revert changes to composer
2121
git checkout composer.json

dev-tools/composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"php": "^7.1"
44
},
55
"require-dev": {
6+
"humbug/box": "~3.7.0",
67
"localheinz/composer-normalize": "^1.1",
78
"maglnet/composer-require-checker": "^2.0",
89
"mi-schi/phpmd-extension": "^4.3",

0 commit comments

Comments
 (0)