- How do I integrate spatie/http-status-check into a Laravel project for automated pre-deployment link validation?
- Wrap the CLI tool in a custom Artisan command (e.g., `php artisan check:links`) and schedule it via Laravel’s scheduler. Use the `spatie/laravel-schedule` package to run checks daily or before deployments. For large sites, batch processing with Laravel queues (e.g., `spatie/queueable`) is recommended to avoid timeouts.
- Can this package check API endpoints or authenticated routes in a Laravel app?
- Yes, extend the `StatusCheck` class to include headers (e.g., `StatusCheck::withHeaders(['Authorization' => 'Bearer token'])`). For API routes, exclude dynamic paths (e.g., `/api/user/{id}`) via regex in the config. Test with Laravel’s `HttpClient` facade to mock responses in unit tests.
- What Laravel versions does spatie/http-status-check support, and are there breaking changes?
- The package is framework-agnostic but works with Laravel 8+ (PHP 7.4+). No Laravel-specific dependencies exist, so version compatibility is tied to Symfony HTTP Client (v5+). Check the [README](https://github.com/spatie/http-status-check) for Symfony updates, as they may require minor adjustments to your wrapper code.
- How do I store historical results in a Laravel database for trend analysis?
- Output results to JSON/CSV and import them into a `status_checks` table with columns like `url`, `status_code`, `checked_at`, and `is_broken`. Use Laravel’s `queue:work` to process batches asynchronously. For analytics, query with Eloquent or use Laravel Scout for full-text search on broken links.
- Is there a way to parallelize checks for large Laravel applications with 10K+ links?
- Yes, use the `--concurrency` flag (e.g., `--concurrency=50`) to control parallel requests. For Laravel, combine this with queue workers: dispatch jobs per route group (e.g., `check:links:batch --urls=admin/*`) and process them in parallel using `spatie/queueable` or Laravel’s `dispatchSync()` for smaller batches.
- How do I exclude dynamic routes (e.g., SPAs, GraphQL) or internal Laravel paths from checks?
- Configure exclusions via the `StatusCheck` class or CLI flags. For example, exclude `/api/*` or `/admin/*` by passing `--exclude=/api/,/admin/` to the CLI. In a Laravel wrapper, use `StatusCheck::withExcludedUrls()` with regex patterns like `~^(?!/api/).*$~` to filter dynamic routes.
- Can I trigger Slack alerts or Jira tickets when broken links are detected in Laravel?
- Yes, parse the output (JSON/CSV) in a Laravel event listener or scheduled task. Use `spatie/laravel-notification-channels-slack` to send alerts, or integrate with Jira’s API via Guzzle. For example, loop through failed checks and dispatch `NotifyAdmins` notifications with the broken URLs.
- What are the alternatives to spatie/http-status-check for Laravel, and when should I use them?
- For Laravel-specific tools, consider `laravel-debugbar` (basic link checking) or `beberlei/assert` for assertions. For enterprise needs, use Screaming Frog API or paid services like Pingdom. Choose this package if you need a lightweight, CLI-driven solution with Laravel integration (e.g., queues, Artisan) and custom output formats.
- How do I test spatie/http-status-check in a Laravel CI pipeline (e.g., GitHub Actions) to fail builds on broken links?
- Add a step to your workflow (e.g., `php artisan check:links --output=results.json`) and validate the JSON output with a script. Use `jq` to filter failed status codes (e.g., `jq '.[] | select(.status != 200)' results.json`) and set `exit 1` if any are found. Example: `if [ $(jq '.[] | select(.status != 200) | length' results.json) -gt 0 ]; then exit 1; fi`.
- The package is archived—will it break with future PHP/Symfony updates? How can I mitigate risks?
- Fork the repository or wrap it in a custom Composer package to isolate dependencies. Monitor Symfony HTTP Client updates and test compatibility. For critical projects, pin the `spatie/http-status-check` version in `composer.json` and override core classes (e.g., `StatusCheck`) to handle deprecations. Consider contributing fixes to the original repo if issues arise.