box.json
```json
{
"main": "report-converter",
"output": "sarif-php-converters.phar",
"force-autodiscovery": true,
"dump-autoload": false,
"exclude-dev-files": false,
"files": [
"autoload.php",
"report-converter.php"
],
"finder": [
{
"name": "*.php",
"exclude": [
"examples",
"resources",
"test",
"tests"
],
"in": [
"vendor-bin/phan",
"vendor-bin/phpcs",
"vendor-bin/phpcs-fixer",
"vendor-bin/phplint",
"vendor-bin/phpmd",
"vendor-bin/phpstan",
"vendor-bin/psalm",
"vendor-bin/twigcs-fixer"
]
}
],
"blacklist": [
"vendor/bamarni/composer-bin-plugin/"
],
"compression": "GZ"
}
```
Output
```bash
box compile -c box.json
```
> output
```text
Box version 4.6.2@29c3585 2024-04-23 19:35:41 UTC
// Loading the configuration file "box.json".
🔨 Building the PHAR "/shared/backups/bartlett/sarif-php-converters/sarif-php-converters.phar"
? Removing the existing PHAR "/shared/backups/bartlett/sarif-php-converters/sarif-php-converters.phar"
? Skipping the Composer compatibility check: the autoloader is not dumped
? No compactor to register
? Adding main file: /shared/backups/bartlett/sarif-php-converters/report-converter
? Adding requirements checker
? Adding binary files
> No file found
? Auto-discover files? Yes
? Exclude dev files? No
? Adding files
> 7172 file(s)
? Generating new stub
- Using shebang line: #!/usr/bin/env php
- Using banner:
> Generated by Humbug Box 4.6.2@29c3585.
>
> @link https://github.com/humbug/box
? Skipping dumping the Composer autoloader
? Removing the Composer dump artefacts
? Compressing with the algorithm "GZ"
> Warning: the extension "zlib" will now be required to execute the PHAR
? Setting file permissions to 0755
* Done.
💡 1 recommendation found:
- The "exclude-dev-files" setting can be omitted since is set to its default value
No warning found.
// PHAR: 7205 files (9.71MB)
// You can inspect the generated PHAR with the "info" command.
// Memory usage: 121.51MB (peak: 123.61MB), time: 8secs
```
Once compiled, try to run the PHAR, but got :
Fatal error: Uncaught RuntimeException: Unable to find "vendor/autoload.php" in "phar:///shared/backups/bartlett/sarif-php-converters/sarif-php-converters.phar"
After investigation, checks with box info sarif-php-converters.phar -l -m flat command, I found that vendor/autoload.php is not included.
The reasonforce-autodiscovery (enabled) and dump-autoload (disabled) are incompatible.
If I removed the dump-autoload setting, and re-compile the PHAR, the vendor/autoload.php is included again and my application is able to run.
Bug report
1.0
)box.json
```json { "main": "report-converter", "output": "sarif-php-converters.phar", "force-autodiscovery": true, "dump-autoload": false, "exclude-dev-files": false, "files": [ "autoload.php", "report-converter.php" ], "finder": [ { "name": "*.php", "exclude": [ "examples", "resources", "test", "tests" ], "in": [ "vendor-bin/phan", "vendor-bin/phpcs", "vendor-bin/phpcs-fixer", "vendor-bin/phplint", "vendor-bin/phpmd", "vendor-bin/phpstan", "vendor-bin/psalm", "vendor-bin/twigcs-fixer" ] } ], "blacklist": [ "vendor/bamarni/composer-bin-plugin/" ], "compression": "GZ" } ```Output
```bash box compile -c box.json ``` > output ```text Box version 4.6.2@29c3585 2024-04-23 19:35:41 UTC // Loading the configuration file "box.json". 🔨 Building the PHAR "/shared/backups/bartlett/sarif-php-converters/sarif-php-converters.phar" ? Removing the existing PHAR "/shared/backups/bartlett/sarif-php-converters/sarif-php-converters.phar" ? Skipping the Composer compatibility check: the autoloader is not dumped ? No compactor to register ? Adding main file: /shared/backups/bartlett/sarif-php-converters/report-converter ? Adding requirements checker ? Adding binary files > No file found ? Auto-discover files? Yes ? Exclude dev files? No ? Adding files > 7172 file(s) ? Generating new stub - Using shebang line: #!/usr/bin/env php - Using banner: > Generated by Humbug Box 4.6.2@29c3585. > > @link https://github.com/humbug/box ? Skipping dumping the Composer autoloader ? Removing the Composer dump artefacts ? Compressing with the algorithm "GZ" > Warning: the extension "zlib" will now be required to execute the PHAR ? Setting file permissions to 0755 * Done. 💡 1 recommendation found: - The "exclude-dev-files" setting can be omitted since is set to its default value No warning found. // PHAR: 7205 files (9.71MB) // You can inspect the generated PHAR with the "info" command. // Memory usage: 121.51MB (peak: 123.61MB), time: 8secs ```Once compiled, try to run the PHAR, but got :
After investigation, checks with
box info sarif-php-converters.phar -l -m flat
command, I found thatvendor/autoload.php
is not included.The reason
force-autodiscovery
(enabled) anddump-autoload
(disabled) are incompatible.If I removed the
dump-autoload
setting, and re-compile the PHAR, thevendor/autoload.php
is included again and my application is able to run.But, as I said https://github.com/box-project/box/issues/580#issuecomment-2326577684, I cannot use the
-d|--working-dir
option of BOX compile (it was my workaround, but it has a limit !)