Laravel Flashcards
7 cards from real LARAVEL practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 7 Laravel flashcards as text
Which Artisan command creates a new middleware class in Laravel?
Answer: php artisan make:middleware CheckAge
The `php artisan make:middleware` command scaffolds a new middleware class in the app/Http/Middleware directory.
In Laravel, where must a newly created middleware be registered to apply it to routes?
Answer: app/Http/Kernel.php
Middleware must be registered in the `$middleware`, `$middlewareGroups`, or `$routeMiddleware` arrays inside `app/Http/Kernel.php`.
What does Laravel's `dd()` helper function do?
Answer: Dumps the given variable and terminates script execution
`dd()` stands for 'dump and die' — it pretty-prints variable contents using Symfony's VarDumper and then halts execution.
Which Laravel facade provides an interface to the application's session store?
Answer: Session
The `Session` facade wraps the underlying session manager, exposing methods like `put()`, `get()`, `forget()`, and `flush()`.
How does Laravel's Eloquent `firstOrCreate()` method differ from `firstOrNew()`?
Answer: firstOrCreate() persists the record to the database; firstOrNew() returns an unsaved model instance
`firstOrCreate()` saves the new model to the database immediately, while `firstOrNew()` returns a new (unsaved) model instance that you must manually call `save()` on.
What is the purpose of Laravel's `config()` helper?
Answer: Retrieve or set configuration values from config files at runtime
`config('app.timezone')` reads from config files, and `config(['app.debug' => true])` sets values at runtime using dot-notation paths.
Which Laravel command caches all configuration files into a single file for faster loading?
Answer: php artisan config:cache
`php artisan config:cache` merges all config files into `bootstrap/cache/config.php`, speeding up configuration access on production.
How this page was made: written with AI tools and published by Nathan Beja, founder of Practice Test Geeks, who is responsible for its content. We have not yet matched this exam's facts to an official source, so confirm fees, dates and rules with the exam body. Not reviewed by a subject-matter expert. Editorial policy