LARAVEL Research & Evidence-Based Practice 2 — Questions and Answers
Question 1: Which Laravel testing tool provides a fluent, expressive API and is the officially recommended alternative to PHPUnit for new Laravel projects?
- Mockery
- Pest PHP (Correct answer)
- Codeception
- Behat
Correct answer: Pest PHP
Pest PHP is the officially recommended testing framework for Laravel, offering a fluent API on top of PHPUnit.
Question 2: When researching a performance bottleneck in Laravel, which built-in facade method lets you measure query execution time by registering a listener?
- Cache::remember()
- DB::listen() (Correct answer)
- Log::channel()
- Queue::monitor()
Correct answer: DB::listen()
DB::listen() registers a callback that fires on every query, providing the SQL and execution time for profiling.
Question 3: According to Laravel best practices, which approach is evidence-based for selecting the correct cache driver for a high-traffic application?
- Always use file cache for simplicity
- Benchmark Redis and Memcached under realistic load before choosing (Correct answer)
- Default to database cache as it requires no extra services
- Use array cache since it is the fastest available
Correct answer: Benchmark Redis and Memcached under realistic load before choosing
Benchmarking Redis and Memcached under realistic traffic patterns is the evidence-based approach to cache driver selection.
Question 4: What artisan command generates a detailed route list that developers use to audit all registered routes in a Laravel application?
- php artisan route:scan
- php artisan route:list (Correct answer)
- php artisan route:inspect
- php artisan route:dump
Correct answer: php artisan route:list
`php artisan route:list` outputs every registered route with its URI, name, middleware, and controller action.
Question 5: Which Laravel package is the de facto standard for generating OpenAPI specs directly from controller annotations?
- laravel-swagger-ui
- L5-Swagger (DarkaOnLine) (Correct answer)
- Laravel Sanctum Docs
- laravel-apidoc-generator
Correct answer: L5-Swagger (DarkaOnLine)
L5-Swagger by DarkaOnLine integrates swagger-php annotations with Laravel to auto-generate OpenAPI 3.0 documentation.
Question 6: When researching memory leaks in a long-running Laravel queue worker, which flag on `queue:work` makes memory issues observable by restarting the worker on limit breach?
- --memory=128 (Correct answer)
- --verbose
- --tries=1
- --max-jobs=100
Correct answer: --memory=128
The --memory flag sets a memory limit in MB; when exceeded the worker restarts, making runaway memory usage detectable.
Question 7: Which tool in the Laravel ecosystem provides a web-based dashboard for real-time monitoring of Redis queue metrics, job throughput, and failure rates?
- Laravel Telescope
- Laravel Nova
- Laravel Horizon (Correct answer)
- Laravel Pulse
Correct answer: Laravel Horizon
Laravel Horizon provides a real-time dashboard for Redis-backed queues, displaying throughput, runtime, and failed jobs.
Which Laravel testing tool provides a fluent, expressive API and is the officially recommended alternative to PHPUnit for new Laravel projects?