- How do I create a Laravel Zero CLI app from scratch?
- Use the `laravel-zero/laravel-zero` package (not this core framework) to scaffold a new project via Composer: `composer create-project laravel-zero/laravel-zero my-cli-app`. This repo contains the core framework, so you’ll need the main project to start building. Follow the [official docs](https://laravel-zero.com) for setup.
- Does Laravel Zero support Laravel 10/11? What’s the PHP version requirement?
- Laravel Zero v12.x requires **PHP 8.1+** and is built for Laravel 10/11. Check the [Packagist page](https://packagist.org/packages/laravel-zero/framework) for version-specific compatibility. If you’re on an older Laravel version, you may need to upgrade or use an older Laravel Zero release.
- Can I use Eloquent in Laravel Zero for database operations?
- Yes, Eloquent is optionally supported. Install it via Composer (`composer require illuminate/database`) and configure your `.env` with database credentials. Laravel Zero reuses Laravel’s Eloquent components, so migrations, models, and queries work as expected. See the [Eloquent docs](https://laravel-zero.com/docs/database) for setup.
- How do I compile my Laravel Zero app into a standalone PHAR file?
- Use the built-in `standalone` command: `php artisan standalone:compile`. This generates a distributable PHAR binary with all dependencies embedded. For advanced options (e.g., custom entry points), refer to the [Standalone Compiler docs](https://laravel-zero.com/docs/build-a-standalone-application).
- What’s the difference between Laravel Zero and Symfony Console?
- Laravel Zero leverages Laravel’s ecosystem (Eloquent, Logging, Prompts) for a more feature-rich CLI experience, while Symfony Console is lighter but lacks built-in database or scheduling. Choose Laravel Zero if you need Laravel integrations; Symfony Console is better for ultra-lightweight tools. Both support commands and arguments.
- How do I add interactive menus or desktop notifications?
- Use `laravel/prompts` for menus and `laravel/mcp` for desktop notifications. Install them via Composer (`composer require laravel/prompts laravel/mcp`), then use the provided helpers in your commands. Example: `Prompt::menu()` for menus or `Notification::send()` for alerts. Docs: [Menus](https://laravel-zero.com/docs/build-interactive-menus) and [Notifications](https://laravel-zero.com/docs/send-desktop-notifications).
- Will Laravel Zero work in Docker or serverless environments?
- Yes, Laravel Zero supports Docker and serverless via PHAR compilation. For Docker, include the PHAR in your image or use the framework directly. For serverless (e.g., AWS Lambda), ensure your runtime supports PHP 8.1+ and bundle dependencies. Test boot time—Laravel Zero is optimized for CLI but may not match Symfony Console’s speed in edge cases.
- How do I integrate Laravel Zero with existing Laravel web apps?
- Share configuration (`.env`), services (bindings in `AppServiceProvider`), and even models between CLI and web apps. Use the same database connection and authentication logic. For shared logic, place reusable code in a `Shared` namespace or package. Laravel Zero’s service container is compatible with Laravel’s.
- What’s Collision, and how do I enable it for error reporting?
- Collision is a package by Nuno Maduro that provides **rich, colored error output** for CLI apps. Install it via `composer require nunomaduro/collision`, then add `CollisionServiceProvider` to your `config/app.php`. Errors will now display with stack traces, syntax highlighting, and actionable insights. Docs: [Collision](https://github.com/nunomaduro/collision).
- Can I use Laravel Zero’s scheduler for cron jobs instead of raw cron scripts?
- Absolutely. Define scheduled commands in `app/Console/Kernel.php` using Laravel’s scheduler syntax (e.g., `Schedule::command('backup:run')->daily()`). Run the scheduler manually (`php artisan schedule:run`) or set up a cron job to trigger it. This replaces ad-hoc scripts with a maintainable, Laravel-native solution. See [Task Scheduling](https://laravel-zero.com/docs/task-scheduling).