Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rseletsk's avatar

rseletsk wrote a reply+100 XP

1w 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

2w 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

2w 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

2w 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

2w 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

2w 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

2w 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

2w 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

2w 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

2w 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

2w 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

2w 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

2w 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

2w 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

2w 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

2w 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

2w 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

2w ago

rseletsk's avatar

rseletsk started a new conversation+100 XP

2w 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

2w 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

2w 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)