Summer Sale! All accounts are 50% off this week.

rseletsk's avatar

rseletsk started a new conversation+100 XP

3d ago

Able to run CLI build, but as another userid when copy to another directory results in runtime error

Using Ubuni Able to run CLI build, but as another userid when copy to another directory results in runtime error PHP Notice: require(): zlib: data error ... PHP Warning: require(phar://box-auto-generated-alias-98dd57535141.phar/.box/bin/check-requirements.php): Failed to open stream: phar error: internal corruption of phar ... (actual filesize mismatch on file ".box/bin/check-requirements.php")

rseletsk's avatar

rseletsk wrote a reply+100 XP

3d ago

How to mark one of my questions as Solved?

Thank You, but do not see three dots or a dropdown

rseletsk's avatar

rseletsk started a new conversation+100 XP

4d ago

Running a CLI Build results in runtime error

Running a CLI Build results in runtime error PHP Fatal error: Uncaught ErrorException: include(): zlib: data error in phar

rseletsk's avatar

rseletsk wrote a reply+100 XP

4d ago

How to mark one of my questions as Solved?

Unable to see 'Mark as Best Answer' or anything else in the My Question thread

rseletsk's avatar

rseletsk started a new conversation+100 XP

4d ago

How to mark one of my questions as Solved?

Unclear how to mark one of my questions as Solved

rseletsk's avatar

rseletsk wrote a reply+100 XP

5d ago

CLI build results in 'Failed to compile the application.'

Pretty Sure this is the issue: This error occurs when you run app:build but your PHP configuration restricts PHAR compilation. By default, most PHP installations have phar.readonly = On, which prevents Laravel-Zero from compiling the application into a standalone PHAR file.

rseletsk's avatar

rseletsk wrote a reply+100 XP

5d ago

CLI build results in 'Failed to compile the application.'

Failed to compile the application.

at vendor/laravel-zero/framework/src/Commands/BuildCommand.php:171 167▕ 168▕ $pharPath = $this->app->basePath($this->getBinary()).'.phar'; 169▕ 170▕ if (! File::exists($pharPath)) { ➜ 171▕ throw new RuntimeException('Failed to compile the application.'); 172▕ } 173▕ 174▕ File::move($pharPath, $this->app->buildsPath($name)); 175▕

  +16 vendor frames

17 canvassettings:35 LaravelZero\Framework\Kernel::handle()

rseletsk's avatar

rseletsk started a new conversation+100 XP

5d ago

CLI build results in 'Failed to compile the application.'

CLI build results in 'Failed to compile the application.'

rseletsk's avatar

rseletsk wrote a reply+100 XP

5d ago

CLI App works, but the build generates runtime error with DB

Thanks - but unclear how to mark my post as closed

rseletsk's avatar

rseletsk started a new conversation+100 XP

1w ago

CLI app: build results in runtime error

CLI app:build results in 'Failed to compile the application'

Output: Failed to compile the application.

at vendor/laravel-zero/framework/src/Commands/BuildCommand.php:171

When debug via ./vendor/laravel-zero/framework/bin/box compile --config box.json --debug [debug] Changed the memory limit from "128MB" to "512M" [debug] Checking BOX_ALLOW_XDEBUG [debug] phar.readonly is disabled [debug] The Xdebug extension is loaded (3.5.3) xdebug.mode=develop [debug] Process restarting (BOX_ALLOW_XDEBUG=internal|3.5.3|1||) [debug] Running: [/opt/remi/php84/root/usr/bin/php, ./vendor/laravel-zero/framework/bin/box, compile, --config, box.json, --debug] [debug] Current memory limit: "512MB" [debug] Checking BOX_ALLOW_XDEBUG [debug] Restarted (90 ms). The Xdebug extension is not loaded

____

/ __ )____ _ __ / __ / __ | |// / // / // /> < /__/_//|_|

Box version 4.7.0@9c2a430 2026-03-18 09:37:27 UTC

// Loading the configuration file "box.json".

🔨 Building the PHAR "/home/rsatpriv/canvassettings/canvassettings.phar"

[debug] Increased the maximum number of open file descriptors from ("1024", "262144") to ("2176", "unlimited") ? Checking Composer compatibility > '/usr/local/bin/composer' '--version' '--no-ansi' > Version detected: 2.8.9 (Box requires ^2.2.0) > Supported version detected ? Registering compactors

  • KevinGH\Box\Compactor\Php
  • KevinGH\Box\Compactor\Json ? Adding main file: /home/rsatpriv/canvassettings/canvassettings ? Adding requirements checker ? Adding binary files

    No file found ? Auto-discover files? No ? Exclude dev files? Yes ? Adding files 8182 file(s) ? Generating new stub

  • Using shebang line: #!/usr/bin/env php
  • Using banner:

    Generated by Humbug Box 4.7.0@9c2a430.

    @link https://github.com/humbug/box ? Dumping the Composer autoloader [debug] Restored the maximum number of open file descriptors

In Box.php line 81:

[ErrorException] chdir(): No such file or directory (errno 2)

rseletsk's avatar

rseletsk wrote a reply+100 XP

1w ago

rseletsk's avatar

rseletsk started a new conversation+100 XP

1w ago

CLI App works, but the build generates runtime error with DB

CLI App Works, but the build generates runtime error with DB: Database file at path [phar:...buildname/database/database.sqlite

Note buildname is the executable build file and Not a directory name

rseletsk's avatar

rseletsk wrote a reply+100 XP

1w ago

Running a CLI build results in runtime error

Resolved this issue via setting DB_DATABASE

rseletsk's avatar

rseletsk wrote a reply+100 XP

1w ago

Running a CLI build results in runtime error

Runtime error is: Database file at path [phar: ... /database/database.sqlite] does not exist

rseletsk's avatar

rseletsk started a new conversation+100 XP

1w ago

Running a CLI build results in runtime error

Have a CLI which built successfully on WSL via appname app:build This results is appname executable in the builds directory In the builds directory and running appname get runtime error: Database file at path ....appname/database/database.sqlite] does not exist But, appname is not a directory since is an executable

rseletsk's avatar

rseletsk wrote a reply+100 XP

1mo ago

Executing app resulting from app:build results in a runtime error

Resolved this via: composer dump-autoload composer install

rseletsk's avatar

rseletsk wrote a reply+100 XP

1mo ago

Steps to move a Laravel application to another computer

Please briefly explain how you use github as opposed to 'build'?

rseletsk's avatar

rseletsk liked a comment+100 XP

1mo ago

Laravel-Zero CLI app:build information

Certainly! Here’s a detailed solution for your Laracasts question:


Yes, using the app:build command provided by Laravel Zero is the recommended (and best) approach to generate a standalone, packaged executable of your CLI app for end users.

Explanation

What does app:build do?

  • The app:build command leverages Box, which is bundled with Laravel Zero.
  • This process compiles your entire application, including dependencies from the vendor directory, into a single executable PHAR file.
  • The resulting .phar (PHP archive) is what you should distribute to your users. They won't need to install Composer or any PHP dependencies to run your CLI app.

How to Use

From your project root, run:

php application app:build

Replace application with the entry point of your Laravel Zero app, if you renamed it.

This will generate a packaged executable (e.g., application.phar) in the builds directory.

What to Distribute

  • Distribute only the generated .phar file to your users.
  • Users can execute your CLI app by running:
    php yourapp.phar
    
    (Or make it executable and run ./yourapp.phar.)

Benefits

  • Clean: Your users don't see your app structure or dependencies.
  • Standalone: No Composer or Laravel Zero knowledge required for your users.
  • Efficient: Smaller, more portable deliverable.

In summary:
Yes, app:build is the best and recommended way to package and distribute your Laravel Zero CLI application.


Reference:
Laravel Zero Documentation – Compiling an Application

Let me know if you have any follow-up questions!

rseletsk's avatar

rseletsk started a new conversation+100 XP

1mo ago

Laravel-Zero CLI app:build information

Have a working laravel-zero CLI app with the entire app structure (ex: vendor directory). Is using appName app:build 'best' to generate a 'packaged' executable for the user?

rseletsk's avatar

rseletsk liked a comment+100 XP

1mo ago

Executing app resulting from app:build results in a runtime error

Ok thank you.

When you need help, it's important to share with us all the informations you can give us.

Without knowing that you were using laravel-zero, it's not possible for us to guess.

So now restart from the beginning ... what have you done step by step until you get the error ?

Step 1 : ... ?

Step 2 : ... ?

...

rseletsk's avatar

rseletsk wrote a reply+100 XP

1mo ago

Executing app resulting from app:build results in a runtime error

Step 1: (Using WSL) Create Laravel CLI 'stub' via laravel-zero new appName Step 2: Update appName to get some functionality working Step 3: Testing -> Verify appName working via ./appname exampleCommand Step 4: Deploy app: php appName app:build -> creates a builds directory with appName Step 5: Cd builds and execute via ./appName exampleCommand Step 6: Get runtime error: Uncaught Dotenv\Exception\InvalidPathException: Unable to read any of the environment file(s) at ... /builds/appName/bootstrap/../.env]. This runtime error is due to there not being a appName directory under builds directory (there is appName executable under builds) Notes: Code in bootstrap/app.php: $dotenv = Dotenv\Dotenv::createImmutable(DIR . '/../');

Why is DIR not returning the full path of the file currently being executed (.../builds) and instead returning (.../builds/appName/bootstrap) ?

Certainly looks like the built appName is returning a different directory path than the Testing appName (since the latter works as expected)

rseletsk's avatar

rseletsk wrote a reply+100 XP

1mo ago

Executing app resulting from app:build results in a runtime error

Code in bootstrap/app.php: $dotenv = Dotenv\Dotenv::createImmutable(DIR . '/../');

Why is DIR not returning the full path of the file currently being executed (.../builds) and instead returning (.../builds/appName/bootstrap) ?

rseletsk's avatar

rseletsk wrote a reply+100 XP

1mo ago

Executing app resulting from app:build results in a runtime error

Ok: Here is summary of current status of issue: Did deploy process of appName app:build which created appName in the (new) builds directory When execute appName get runtime error Uncaught Dotenv\Exception\InvalidPathException: Unable to read any of the environment file(s) at ... /builds/appName/bootstrap/../.env]. This runtime error is due to there not being a appName directory under builds directory (there is appName executable under builds)

Why is it looking for appName directory under builds directory?

rseletsk's avatar

rseletsk liked a comment+100 XP

1mo ago

Executing app resulting from app:build results in a runtime error

Do you, though? In which path is it? The error clearly says it doesn't exist, or it's not readable due to improper permissions.

rseletsk's avatar

rseletsk liked a comment+100 XP

1mo ago

Steps to move a Laravel application to another computer

Easiest is to use github, other than that you can use a mounted share, or a regular usb stick.

rseletsk's avatar

rseletsk wrote a reply+100 XP

1mo ago

Executing app resulting from app:build results in a runtime error

From created a Laravel CLI app via laravel-zero new applicationName

rseletsk's avatar

rseletsk wrote a reply+100 XP

1mo ago

Executing app resulting from app:build results in a runtime error

From created a Laravel CLI app via laravel-zero new applicationName

rseletsk's avatar

rseletsk wrote a reply+100 XP

1mo ago

Executing app resulting from app:build results in a runtime error

From created a Laravel CLI app via laravel-zero new applicationName

rseletsk's avatar

rseletsk wrote a reply+100 XP

1mo ago

Executing app resulting from app:build results in a runtime error

Is best practice to deploy the application to production with app:build and use the production executable?

rseletsk's avatar

rseletsk wrote a reply+100 XP

1mo ago

Executing app resulting from app:build results in a runtime error

On remote serverthe appname above the builds directory executes without any runtime error

rseletsk's avatar

rseletsk wrote a reply+100 XP

1mo ago

Executing app resulting from app:build results in a runtime error

On local laptop (WSL) the appname above the builds directory executes without any runtime error

rseletsk's avatar

rseletsk wrote a reply+100 XP

1mo ago

Executing app resulting from app:build results in a runtime error

On local laptop (WSL): php appname app:build does work are generates the deployed executable appname under the builds directory. But, when execute appname (via ./appname) get: PHP Fatal error: Uncaught Dotenv\Exception\InvalidPathException: Unable to read any of the environment file(s) at ... bootstrap/../.env].

rseletsk's avatar

rseletsk wrote a reply+100 XP

1mo ago

Executing app resulting from app:build results in a runtime error

php appname app:build -vvv results in runtime error: [_HumbugBox6ab58bf96c33\KevinGH\Box\Composer\Throwable\UndetectableComposerVersion] Could not detect the Composer version: The command "'/usr/local/bin/compose r' '--version' '--no-ansi'" failed.

Exit Code: 1(General error)

Working directory: /home/whatever

Output:

PHP's phar extension is missing. Composer requires it to run. Enable the ex tension or recompile php without --disable-phar then try again.

rseletsk's avatar

rseletsk wrote a reply+100 XP

1mo ago

rseletsk's avatar

rseletsk started a new conversation+100 XP

1mo ago

Executing app resulting from app:build results in a runtime error

Executing app resulting from app:build results in a runtime error: PHP Fatal error: Uncaught Dotenv\Exception\InvalidPathException: Unable to read any of the environment file(s) at ... bootstrap/../.env].

rseletsk's avatar

rseletsk liked a comment+100 XP

1mo ago

Steps to move a Laravel application to another computer

Certainly! Here’s a step-by-step solution to move a Laravel application to another computer, even if the operating systems are different:


Steps to Move a Laravel Application to Another Computer

  1. Copy the Project Files

    • Copy your entire Laravel project directory (excluding /vendor and /node_modules folders as they can be large and can be restored).
    • Optionally, you can use Git to pull from a repository if your project is version-controlled.
  2. Install PHP, Composer, and Other Requirements

    • Make sure the new computer has PHP (match your Laravel version requirements), Composer, and a web server (like Apache or Nginx) installed.
    • Install Node.js and npm if you use frontend assets built with Mix/Vite.
  3. Transfer the Project

    • Paste/move your project folder into the desired directory on the new machine.
  4. Install Composer Dependencies

    • In your new machine, open a terminal in the project root and run:
      composer install
      
  5. Install Node Dependencies (Optional)

    • If you use Laravel Mix or Vite for assets:
      npm install
      
    • Then build your assets as needed:
      npm run dev
      # or for production:
      npm run build
      
  6. Set Up Environment Configuration

    • Copy .env.example to .env:
      cp .env.example .env
      
    • Update .env with the new database, mail, and other relevant settings for the new environment.
  7. Generate Application Key

    php artisan key:generate
    
  8. Set Up the Database

    • Create a new database on the target machine.
    • If you have an existing database, export it (mysqldump, phpMyAdmin, etc.) from the old computer and import it to the new one.
  9. Run Migrations/Seeders (if needed)

    php artisan migrate --seed
    
    • Only if you want to migrate and seed the database from scratch.
  10. Set Correct Permissions (Linux/Mac)

    chmod -R 775 storage bootstrap/cache
    
  11. Start the Application

    • Start the local development server:
      php artisan serve
      
    • Or set up your web server (Apache/Nginx) to serve the project.

That’s it! Your Laravel app should now be running on the new computer.


Extra Tips:

  • Don’t forget to transfer any storage/app/public files if your app uses local file storage.
  • If you’re using git, pushing/pulling your code makes transfer much easier.
  • If you face permission issues, verify your web server user has access to the necessary directories.
rseletsk's avatar

rseletsk started a new conversation+100 XP

2mos ago

Steps to move a Laravel application to another computer

Looking for basic steps to move a Laravel application to another computer (different Operating System)