- How do I install and use `spatie/laravel-visit` in my Laravel project?
- Install via Composer: `composer require spatie/laravel-visit`. Then run `php artisan visit /route-name` or `php artisan visit --route=route.name`. For colorized output, install `bat` (HTML) and `jq` (JSON) globally. No additional configuration is needed.
- Does this package work with Laravel 10+ and PHP 8.1+?
- Yes, `spatie/laravel-visit` is officially supported for Laravel 10+ and requires PHP 8.1+. Check the package’s `composer.json` for exact version constraints, as minor updates may extend compatibility.
- Can I authenticate a user before visiting a protected route?
- Absolutely. Use the `--user` flag: `php artisan visit /dashboard --user=admin`. This leverages Laravel’s authentication system, so ensure the user exists and the guard is properly configured.
- Will this package interfere with my existing Laravel middleware or route caching?
- No, the package respects Laravel’s middleware pipeline and works seamlessly with cached routes (`php artisan route:cache`). It simulates requests just like a browser or API client would.
- How can I integrate `laravel-visit` into my CI/CD pipeline for automated route testing?
- Use the `--json` flag to output machine-readable JSON: `php artisan visit /health-check --json`. Pipe the output to `jq` or parse it in your CI script (e.g., GitHub Actions) to validate responses programmatically.
- Is there a way to visit routes by name instead of URL?
- Yes, use the `--route` flag: `php artisan visit --route=dashboard.show`. This is especially useful for dynamic or API routes where URLs may change but names remain consistent.
- What if my route returns a 500 error? Will the package show the actual error details?
- The package displays the raw response, including error pages or JSON error payloads. For debugging, combine with `php artisan route:list` or Laravel’s `--verbose` flags to isolate issues.
- Can I use this package for load testing or performance benchmarking?
- No, this package is designed for single-request debugging, not load testing. For performance benchmarking, use tools like Laravel Dusk, Pest, or dedicated load-testing packages like `spatie/laravel-load-testing`.
- Are there alternatives to `spatie/laravel-visit` for CLI route inspection?
- Yes, alternatives include manual `curl` commands, Laravel Dusk (for browser-like testing), or Pest’s HTTP assertions. However, `laravel-visit` offers a Laravel-native, colorized, and user-authentication-aware solution tailored for quick CLI debugging.
- How do I customize or extend the `visit` command for my specific needs?
- The package is open-source and can be extended via service providers or by publishing its configuration (though none exists by default). Fork the repo or submit a PR to Spatie for shared improvements, or override the command logic in your app’s `AppServiceProvider`.