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

rseletsk's avatar

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?

0 likes
1 reply
LaryAI's avatar
Level 58

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!

1 like

Please or to participate in this conversation.