Laravel Architecture & Basics
1
What is the primary function of Laravel's routing system?
Manage database connections
Define web request handling
Control user authentication
Handle file uploads
2
How do you define a basic GET route in Laravel?
Route::post('url', 'Controller@method');
Route::get('url', 'Controller@method');
Route::put('url', 'Controller@method');
Route::any('url', 'Controller@method');
3
Which method defines a fallback route in Laravel?
Route::catch();
Route::backup();
Route::fallback();
Route::final();
4
Which of the following creates a route to call a controller method?
Route::controller('HomeController');
Route::get('home', 'HomeController@index');
Route::link('home', 'HomeController@index');
Route::method('home', 'HomeController@index');
5
Which method in a controller is called automatically when defining an invokable route?
handle()
__invoke()
process()
__handle()
6
What is the purpose of resource routes in Laravel?
To define routes for API resources
To automatically create routes for CRUD operations
To manage static routes
To handle middleware
7
How can you pass a variable from a controller to a view in Laravel?
return view('viewName')->with('variable', $value);
return view('viewName', ['variable' => $value]);
return redirect()->with('variable', $value);
Both a and b
8
Which method can be used to return a flash message to the session?
return view()->flash('message', $value);
return redirect()->back()->with('message', $value);
session()->flash('message', $value);
Both b and c
9
How do you access a variable in a Blade view?
{{ variable }}
= $variable ?>
@{{ variable }}
All of the above
10
What does CSRF stand for?
Cross-Site Request Form
Cross-Site Request Forgery
Client-Side Request Forgery
Cross-Site Resource Form
11
Which directive is used in Laravel forms to protect against CSRF?
@csrf_token
@csrf
@secure
@token
12
How is the CSRF token stored in a Laravel application?
In cookies
In session data
In local storage
In a database
13
How can you pass the CSRF token in AJAX requests?
Set the X-CSRF-TOKEN header
Include it in the request body
It’s not necessary for AJAX requests
Pass it in the URL
14
Which method is used to validate incoming request data?
validate()
check()
verify()
validateRequest()
15
Where are exceptions handled in Laravel?
app/Exceptions/Handler.php
config/app.php
app/Http/Kernel.php
routes/web.php