Closed khanakia closed 1 year ago
Could it be that your artisan file is not included? You can verify that by using the --debug option and inspect the dumped directory.
Alternatively I would need to check what LaravelZero do to make it work.
I have added a fresh laravel installation and i have not changed a single file. The only file i created is box.json in project root
i have uploaded the code here https://github.com/khanakia/box_test
You can check here's the debug output
@khanakia, I cloned your repo and tried it with Box 4.3.8 and had no problems. I'm on an Ubuntu box.
@netbrothers-tr Did you run composer install
command first? It seems you compiled without vendor directory.
@netbrothers-tr Did you run
composer install
command first? It seems you compiled without vendor directory.
@khanakia, I actually didn't and now I'm wondering how this even worked. ;-) Thanks for the hint.
However, I ran box again, this time with all dependencies installed. It turns out, the line "@php artisan package:discover --ansi" in the "scripts" > "post-autoload-dump" section of the composer file cannot be executed in box context, because it is run from some other directory.
You can fix this in two ways:
@theofidry, is there something you could tweak using the --working-dir= composer option?
@netbrothers-tr Also how can i fix the file path issues ?
Basically, i trying to phar the whole laravel application and want be able to run it.
PHP Warning: require_once(phar:///Users/test/Downloads/box_test-main/public/index.phar/public/../bootstrap/app.php): Failed to open stream: phar error: "bootstrap/app.php" is not a file in phar "/Users/test/Downloads/box_test-main/public/index.phar" in phar:///Users/test/Downloads/box_test-main/public/index.phar/public/index.php on line 47
@khanakia, how did you get this warning? And some more questions:
If you are trying to build a command-line tool, consider using Laravel Zero instead.
Basically, I was trying to protect the source code in some way to make it hard to be added new features. Anyway i see that's won't be possible this way. Thanks :smiley:
Okay, now I see your motivation. Thanks for clarifying! Well, although it should be technically possible to create a Phar from a whole web application, it might become pretty difficult. If obfuscation is the main goal, there is quiet a number of tools out there, which do the job. To protect your code completely, ionCube comes to my mind, which is a commercial solution.
Bug report
box.json.dist
```json { "main": "public/index.php", "chmod": "0755", "exclude-composer-files": false } ```Output
```bash $ box compile > output ? Removing the existing PHAR "/test/public/index.phar" ? Checking Composer compatibility > Supported version detected ? No compactor to register ? Adding main file: /test/public/index.php ? Adding requirements checker ? Adding binary files > No file found ? Auto-discover files? Yes ? Exclude dev files? Yes ? Adding files > 7931 file(s) ? Generating new stub - Using shebang line: #!/usr/bin/env php - Using banner: > Generated by Humbug Box 4.3.8@5534406. > > @link https://github.com/humbug/box ? Dumping the Composer autoloader In ComposerOrchestrator.php line 207: Could not dump the autoloader. In ComposerOrchestrator.php line 210: The command "'/usr/local/bin/composer' 'dump-autoload' '--classmap-authoritative' '--no-dev' '--ansi'" failed. Exit Code: 1(General error) Working directory: /private/var/folders/qk/jzsg52995wn53dv8bw62dl1w0000gn/T/box/Box56685 Output: ================ Generating optimized autoload files (authoritative) Could not open input file: artisan Error Output: ================ > Illuminate\Foundation\ComposerScripts::postAutoloadDump > @php artisan package:discover --ansi Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1 compile [--debug] [--no-parallel] [--no-restart] [--dev] [--no-config] [--with-docker] [--composer-bin COMPOSER-BIN] [--allow-composer-check-failure] [-c|--config CONFIG] [-d|--working-dir WORKING-DIR] ```It should compile and create a phar from laravel project but it do not