- Can I use spatie/laravel-cronless-schedule in production instead of cron?
- No, this package is not recommended for production. It lacks persistence across process restarts and distributed task coordination. For production, use Laravel Forge, Envoyer, or AWS EventBridge instead.
- How do I install this package for local development?
- Run `composer require spatie/laravel-cronless-schedule --dev` to install it as a dev dependency. Then execute `php artisan schedule:run-cronless` in your terminal to start the scheduler loop.
- Will this work with Laravel 11?
- Yes, the package supports Laravel 8.x through 11.x. Check the `composer.json` constraints in the package for exact version requirements.
- Does this block HTTP requests or other PHP processes?
- No, it uses ReactPHP’s event loop to run non-blockingly, allowing concurrent HTTP requests. However, avoid using it alongside other async PHP processes like Laravel Horizon without testing concurrency.
- How do I test scheduled jobs in CI/CD (e.g., GitHub Actions)?
- Add `php artisan schedule:run-cronless &` to your workflow, then simulate time with `sleep 60` in tests. Avoid relying on exact timing; use Laravel’s logging or `CronlessSchedule::getLastRunTime()` for verification.
- What if my CI/CD environment kills the process (e.g., Kubernetes, serverless)?
- The command runs indefinitely, so test SIGTERM handling in your environment. Use tools like PM2 or Docker’s `restart: unless-stopped` to manage process longevity.
- Can I change the frequency from 1 minute?
- Yes, pass a custom frequency in seconds via the `--frequency` option. For example, `php artisan schedule:run-cronless --frequency=30` runs every 30 seconds.
- Will this work in Docker containers or serverless (AWS Lambda)?
- Yes, it’s ideal for ephemeral environments. In Docker, run it as a detached process (`&`). In Lambda, ensure the timeout exceeds the loop’s duration (e.g., 60+ seconds).
- How do I manually trigger a schedule run without waiting for the next interval?
- Press Enter in the terminal where `schedule:run-cronless` is running to manually trigger an immediate execution of the scheduler.
- Are there alternatives if ReactPHP is blocked (e.g., shared hosting)?
- If ReactPHP or `pcntl` extensions are unavailable, consider using a lightweight cron emulator like `spatie/laravel-schedule-testing` for tests or stick to cron in production.