Laravel Certified Developer — Questions and Answers
Question 1: What is the role of Gates in Laravel's authorization system?
- To define simple closure-based authorization rules for actions (Correct answer)
- To manage API rate limiting
- To enforce database row-level security
- To authenticate third-party OAuth providers
Correct answer: To define simple closure-based authorization rules for actions
Gates are closures registered in a service provider that determine whether a user is authorized to perform a given action.
Question 2: Which PHPStan/Larastan level enforces the strictest type checks in a Laravel project?
- Level 7
- Level MAX
- Level 9 (Correct answer)
- Level 5
Correct answer: Level 9
PHPStan level 9 is the highest standard level, checking the most type-safety rules including dead code and mixed type usage.
Question 3: What risk does Laravel's default session driver 'file' pose in a multi-server deployment?
- File sessions bypass CSRF verification
- File sessions are faster, increasing DoS risk
- File sessions do not support encryption
- Sessions stored on one server are unavailable on others, causing authentication failures and potential session hijacking via predictable paths (Correct answer)
Correct answer: Sessions stored on one server are unavailable on others, causing authentication failures and potential session hijacking via predictable paths
File-based sessions are local to each server, so load-balanced users lose their session — and predictable file paths can be exploited if file permissions are wrong.
Question 4: Which Blade directive in a parent layout outputs content defined in child view sections?
- @render
- @section
- @yield (Correct answer)
- @show
Correct answer: @yield
@yield('section-name') in a parent layout renders whatever content a child view injects into that named section.
Question 5: In Laravel broadcasting, what is the purpose of the `ShouldBroadcast` interface on an event?
- Prevents the event from being broadcast to prevent duplicate notifications
- Logs the event to all connected monitoring services
- Ensures the event is queued before being dispatched
- Marks the event to be broadcast over WebSocket channels when fired (Correct answer)
Correct answer: Marks the event to be broadcast over WebSocket channels when fired
Implementing `ShouldBroadcast` on an event tells Laravel to broadcast the event payload to the specified channel(s) via the configured driver (Pusher, Ably, or Laravel WebSockets).
Question 6: What is the correct Blade directive to implement a switch/case structure?
- @match with @when and @endmatch
- @choose with @option and @endchoose
- @switch with @case and @endswitch (Correct answer)
- @select with @option and @endselect
Correct answer: @switch with @case and @endswitch
Blade provides @switch, @case, @break, @default, and @endswitch directives mirroring PHP's switch statement.
Question 7: Laravel's `throttle` middleware helps meet which specific compliance or security control requirement?
- Protecting against brute-force attacks on authentication endpoints, satisfying account lockout controls required by frameworks like NIST 800-63 (Correct answer)
- Enforcing TLS by rejecting unencrypted HTTP requests
- Preventing SQL injection by limiting query execution speed
- Encrypting sensitive fields before database storage
Correct answer: Protecting against brute-force attacks on authentication endpoints, satisfying account lockout controls required by frameworks like NIST 800-63
Rate limiting via `throttle` directly addresses brute-force risk on login endpoints, which is an account lockout/rate control required by NIST 800-63 and similar frameworks.
Question 8: What is the role of professional journals in Laravel PHP Framework practice?
- They only benefit academics
- They disseminate current research, best practices, and professional developments (Correct answer)
- They are outdated by publication time
- They are optional reading
Correct answer: They disseminate current research, best practices, and professional developments
This is fundamental to Laravel PHP Framework practice. They disseminate current research, best practices, and professional developments represents the professional standard for research in the LARAVEL certification framework.
Question 9: Which middleware is responsible for protecting routes against Cross-Site Request Forgery in Laravel?
- \App\Http\Middleware\VerifyCsrfToken (Correct answer)
- \App\Http\Middleware\Authenticate
- \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth
- \Illuminate\Session\Middleware\StartSession
Correct answer: \App\Http\Middleware\VerifyCsrfToken
The VerifyCsrfToken middleware checks every POST/PUT/PATCH/DELETE request for a valid CSRF token.
Question 10: What does the `@can` Blade directive do in Laravel templates?
- Verifies that a CSRF token is valid
- Checks if a user has a specific role
- Renders content only if the authenticated user is authorized for the given ability (Correct answer)
- Conditionally renders if the user is an admin
Correct answer: Renders content only if the authenticated user is authorized for the given ability
The @can directive calls the authorization gate and only renders the enclosed Blade content when the user passes the authorization check.
Question 11: What does `Route::fallback()` do in Laravel?
- Logs unmatched routes to the database
- Handles any request that does not match any defined routes (Correct answer)
- Redirects to the home page on 404
- Serves a cached version of the last matched route
Correct answer: Handles any request that does not match any defined routes
Route::fallback() registers a route that is invoked when no other route matches the incoming request URI.
Question 12: What is a route prefix used for in Laravel route groups?
- Adding authentication to all grouped routes
- Setting the HTTP method for all grouped routes
- Prepending a URI segment to all routes in the group (Correct answer)
- Naming all routes in the group automatically
Correct answer: Prepending a URI segment to all routes in the group
The prefix option in Route::group() prepends a common URI segment to every route defined within that group.
Question 13: How do you render all content pushed to a named Blade stack?
- @output('scripts')
- @render('scripts')
- @show('scripts')
- @stack('scripts') (Correct answer)
Correct answer: @stack('scripts')
@stack('stack-name') outputs everything that was pushed to that stack via @push directives throughout the view hierarchy.
Question 14: What is the purpose of Laravel Sanctum?
- To encrypt all database columns
- To provide lightweight API token authentication and SPA authentication (Correct answer)
- To manage OAuth2 server flows for third-party apps
- To rate-limit authentication attempts
Correct answer: To provide lightweight API token authentication and SPA authentication
Laravel Sanctum offers a simple token-based authentication system for SPAs, mobile apps, and simple API token issuance without full OAuth2 complexity.
Question 15: What does the `$hidden` property do in a Laravel Eloquent model?
- Marks fields as encrypted at rest
- Hides columns from query results
- Excludes listed attributes from array and JSON serialization (Correct answer)
- Prevents attributes from being stored in the database
Correct answer: Excludes listed attributes from array and JSON serialization
Attributes listed in $hidden are omitted when the model is converted to an array or JSON, commonly used for passwords and tokens.
Question 16: Which Artisan command generates a new policy class in Laravel?
- php artisan policy:make PostPolicy
- php artisan generate:policy PostPolicy
- php artisan create:policy PostPolicy
- php artisan make:policy PostPolicy --model=Post (Correct answer)
Correct answer: php artisan make:policy PostPolicy --model=Post
php artisan make:policy generates a policy class, and the --model flag pre-fills CRUD authorization method stubs for the given model.
Question 17: In Laravel, which method on a job class causes it to be retried only after a delay?
- releaseAfter()
- delay()
- retryAfter()
- backoff() (Correct answer)
Correct answer: backoff()
The `backoff()` method (or property) on a job defines the number of seconds to wait before retrying a failed attempt.
Question 18: Which method verifies a plain-text password against a stored hash in Laravel?
- Hash::verify($plainText, $hashedValue)
- Hash::check($plainText, $hashedValue) (Correct answer)
- Hash::validate($plainText, $hashedValue)
- Hash::compare($plainText, $hashedValue)
Correct answer: Hash::check($plainText, $hashedValue)
Hash::check() compares a plain-text string against a hashed value and returns true if they match, used during login validation.
Question 19: In Laravel, what is the role of the `AppServiceProvider`?
- Handles HTTP request authentication
- Defines all API routes
- Bootstraps application services and bindings on startup (Correct answer)
- Manages database connection pooling
Correct answer: Bootstraps application services and bindings on startup
`AppServiceProvider` is a central place to register service container bindings and perform bootstrap logic when the app starts.
Question 20: How do LARAVEL professionals build trust with clients or stakeholders?
- Through consistent competence, transparency, reliability, and ethical behavior (Correct answer)
- Through marketing only
- Through competitive pricing only
- By always agreeing with clients
Correct answer: Through consistent competence, transparency, reliability, and ethical behavior
This is fundamental to Laravel PHP Framework practice. Through consistent competence, transparency, reliability, and ethical behavior represents the professional standard for communication in the LARAVEL certification framework.
Question 21: What does the `middleware` method do when chained onto a route definition in Laravel?
- Assigns middleware to filter the request before it reaches the controller (Correct answer)
- Caches the route response
- Validates the request payload
- Logs the request to the database
Correct answer: Assigns middleware to filter the request before it reaches the controller
Chaining ->middleware() on a route assigns one or more middleware classes that intercept and filter the HTTP request.
Question 22: What is Laravel Passport primarily used for?
- Managing user roles and permissions
- Sending transactional emails
- Full OAuth2 server implementation for API authentication (Correct answer)
- Scheduling recurring console commands
Correct answer: Full OAuth2 server implementation for API authentication
Laravel Passport provides a complete OAuth2 server so your application can issue and validate API access tokens.
Question 23: Which HTTP verb method would you use to define a route that only responds to DELETE requests?
- Route::destroy()
- Route::erase()
- Route::delete() (Correct answer)
- Route::remove()
Correct answer: Route::delete()
Route::delete() registers a route that responds exclusively to the HTTP DELETE verb.
Question 24: What does `$this->actingAs($user, 'api')` do in a Laravel test?
- Authenticates the user via the api guard for the test request (Correct answer)
- Generates a JWT for the user
- Switches the default guard to api permanently
- Creates a Sanctum token for the user
Correct answer: Authenticates the user via the api guard for the test request
actingAs accepts an optional guard name so the test authenticates through that specific guard rather than the default web guard.
Question 25: Which command generates a new middleware class in Laravel?
- php artisan create:middleware MiddlewareName
- php artisan generate:middleware MiddlewareName
- php artisan make:middleware MiddlewareName (Correct answer)
- php artisan middleware:make MiddlewareName
Correct answer: php artisan make:middleware MiddlewareName
The php artisan make:middleware command scaffolds a new middleware class in app/Http/Middleware/.
Question 26: What static analysis tool integrates with Laravel via the larastan package?
- Psalm
- PHPStan (Correct answer)
- Rector
- Phan
Correct answer: PHPStan
Larastan is a PHPStan extension that adds Laravel-specific type inference so PHPStan can analyze Laravel projects accurately.
Question 27: Which method allows you to redirect a user to a named route in a Laravel controller?
- return response()->route('route.name')
- return view()->route('route.name')
- return redirect()->route('route.name') (Correct answer)
- return back()->route('route.name')
Correct answer: return redirect()->route('route.name')
The redirect()->route() method creates an HTTP redirect response pointing to the URL of a named route.
Question 28: What is the benefit of interdisciplinary collaboration in Laravel PHP Framework practice?
- It slows down decision making
- It is only for complex projects
- It brings diverse expertise and perspectives that improve outcomes and innovation (Correct answer)
- It creates confusion
Correct answer: It brings diverse expertise and perspectives that improve outcomes and innovation
This is fundamental to Laravel PHP Framework practice. It brings diverse expertise and perspectives that improve outcomes and innovation represents the professional standard for practical in the LARAVEL certification framework.
Question 29: What does `Route::group()` allow you to do in Laravel?
- Share route attributes like prefix and middleware across multiple routes (Correct answer)
- Limit route execution time
- Create resourceful route collections
- Bundle routes into a compiled cache
Correct answer: Share route attributes like prefix and middleware across multiple routes
Route::group() lets you share attributes such as middleware, prefix, or namespace across a set of routes.
Question 30: How do you define a named route in Laravel?
- Route::get('/path', 'Controller@method', 'route.name')
- Route::named('route.name', '/path', 'Controller@method')
- Route::get('/path', 'Controller@method')->name('route.name') (Correct answer)
- Route::name('route.name')->get('/path', 'Controller@method')
Correct answer: Route::get('/path', 'Controller@method')->name('route.name')
Named routes are created by chaining the ->name() method onto the route definition.
Question 31: How do you include a Blade sub-view (partial) inside another Blade template?
- @extend('partial')
- @render('partial')
- @include('partial') (Correct answer)
- @use('partial')
Correct answer: @include('partial')
@include('view.name') embeds another Blade view at that location and shares all variables from the parent scope.
Question 32: Which Blade directive allows you to include a view conditionally based on a boolean expression?
- @includeWhen($bool, 'view') (Correct answer)
- @includeIf($bool, 'view')
- @renderWhen($bool, 'view')
- @conditionalInclude('view', $bool)
Correct answer: @includeWhen($bool, 'view')
@includeWhen($condition, 'view.name') renders the included view only when the first argument evaluates to true.
Question 33: What is the difference between the `web` and `api` authentication guards in Laravel?
- web uses OAuth2 and api uses basic auth
- web is for admin users and api is for regular users
- web routes are encrypted while api routes are plain
- web uses session/cookie storage while api uses token-based stateless authentication (Correct answer)
Correct answer: web uses session/cookie storage while api uses token-based stateless authentication
The web guard maintains state via session cookies, whereas the api guard is stateless and authenticates each request via a token.
Question 34: How do you check if a user is authenticated in a Laravel controller?
- session()->authenticated()
- auth()->check() (Correct answer)
- user()->exists()
- Auth::loggedIn()
Correct answer: auth()->check()
auth()->check() returns a boolean indicating whether the current session has an authenticated user.
Question 35: Which Laravel testing helper checks that a Blade view was rendered with specific data in a unit test?
- $this->view('view.name', $data)->assertSee() (Correct answer)
- View::assertData()
- view()->assertRenderedWith()
- $this->assertView()
Correct answer: $this->view('view.name', $data)->assertSee()
The view() test helper returns a TestView instance on which you can call assertSee, assertViewHas, and similar assertions.
Question 36: Which method is used to generate a URL for a named route in a Laravel Blade template?
- path('route.name')
- url('route.name')
- route('route.name') (Correct answer)
- link('route.name')
Correct answer: route('route.name')
The route() helper function generates a URL for a given named route in both Blade templates and PHP code.
Question 37: Which Blade directive includes a view only if that view file actually exists?
- @safe_include('view')
- @include('view') ?? null
- @tryInclude('view')
- @includeIf('view') (Correct answer)
Correct answer: @includeIf('view')
@includeIf('view.name') silently skips rendering if the specified view file does not exist, preventing errors.
Question 38: What is the purpose of the `signed` middleware in Laravel?
- To validate that incoming URLs have a valid cryptographic signature (Correct answer)
- To authenticate webhook payloads
- To verify the user's digital certificate
- To sign response headers with the app key
Correct answer: To validate that incoming URLs have a valid cryptographic signature
The signed middleware ensures the URL contains a valid HMAC signature generated by URL::signedRoute(), protecting against URL tampering.
Question 39: What Artisan command caches all application routes to speed up route registration?
- php artisan routes:save
- php artisan optimize:routes
- php artisan route:cache (Correct answer)
- php artisan route:compile
Correct answer: php artisan route:cache
php artisan route:cache serializes all routes into a single cached file, reducing the overhead of route registration on each request.
Question 40: What does Laravel's `encrypt()` helper do?
- Hashes a value with bcrypt
- Base64-encodes a string
- Encrypts a value using AES-256-CBC with the application's APP_KEY (Correct answer)
- Signs a value with an HMAC digest
Correct answer: Encrypts a value using AES-256-CBC with the application's APP_KEY
The encrypt() helper uses Laravel's Encrypter service to AES-256-CBC encrypt a payload, also signing it to prevent tampering.
Question 41: What does `php artisan migrate:fresh` do differently from `php artisan migrate:refresh`?
- There is no functional difference
- Fresh drops all tables and re-runs migrations; refresh rolls back then re-runs (Correct answer)
- Fresh only runs pending migrations; refresh re-runs all
- Fresh rolls back migrations; refresh drops all tables
Correct answer: Fresh drops all tables and re-runs migrations; refresh rolls back then re-runs
`migrate:fresh` drops every table (ignoring migration history), while `migrate:refresh` uses the `down()` methods to roll back.
Question 42: Which PHPUnit annotation is used to run a single test method multiple times with different data sets in Laravel tests?
- @group
- @covers
- @dataProvider (Correct answer)
- @depends
Correct answer: @dataProvider
@dataProvider links a test method to a method that returns arrays of argument sets, running the test once per set.
Question 43: What is the purpose of the @once directive in Blade?
- Ensures a block of HTML is rendered only once even if the view is included multiple times (Correct answer)
- Prevents AJAX from re-rendering a block
- Ensures a block is only rendered on the initial page load
- Caches the output of a block permanently in Redis
Correct answer: Ensures a block of HTML is rendered only once even if the view is included multiple times
@once ... @endonce ensures its enclosed content is only output once, even if the surrounding view or component is rendered multiple times.
Question 44: Which of the following files does Laravel use to set up database connections?
- setting.php
- None of the above
- config.php
- .ENV file (Correct answer)
Correct answer: .ENV file
Laravel primarily uses the `.env` file for environment-specific configuration, which includes sensitive details like database connection settings. This file stores critical information such as the database host, username, password, and database name. These values are then loaded into the application's configuration, allowing for flexible and secure management of environment settings.
Question 45: Which method on a `TestResponse` asserts that a redirect goes to a named route?
- assertNamedRedirect
- assertRouteRedirect
- assertRedirect
- assertRedirectToRoute (Correct answer)
Correct answer: assertRedirectToRoute
assertRedirectToRoute resolves the named route and checks that the response Location header points to it.
Laravel Certified Developer
The Laravel Certified Developer exam validates proficiency in building web applications with the Laravel PHP framework, covering routing, Eloquent ORM, Blade templates, authentication, and testing. Candidates must demonstrate working knowledge of Laravel v12+ and modern PHP features.
Exam Rules
- You can skip questions and return to them later
- Flag questions for review before submitting
- No feedback shown until you submit the entire exam
- Unanswered questions count as wrong — answer everything
- 10 pretest questions are mixed in and don't affect your score
- Timer auto-submits when time runs out
- Your progress is auto-saved every 30 seconds