Friday, 3 April 2020

Laravel interview questions for 3 year experienced

Laravel interview questions for 3 year experienced

Question: Explain validation in Laravel.?
ValidatesRequests is the trait which is been used by Laravel classes for validating input data.
public function store(Request $request)
   $validatedData = $request->validate([
       'title' => 'required|unique:posts|max:255',
       'description' => 'required',
       'email' => 'required',

Question: What is CSRF protection and CSRF token?
Cross-site forgeries are a type of malicious exploit where unauthorized person/command do/run on behalf of the authenticated user.
Laravel generates a CSRF "token" automatically for each active user session.
This token is used to verify that the authenticated user is the one actually making the requests.

Question: What is Laravel Dusk?
It is expressive, easy-to-use browser automation and testing API.

Question: What is Laravel Echo?
Event broadcasting, evolved. Bring the power of WebSockets to your application without the complexity.

Question: How do you install Laravel?
Laravel utilizes Composer to manage its dependencies. So, before using Laravel, make sure we have Composer installed on your machine.

Question: Explain Binding Instances?
You may also bind an existing object instance into the container using the instance method.
$api = new HelpSpot\API(new HttpClient);
$this->app->instance("HelpSpot\API", $api);

Question: Explain Extending Bindings?
$this->app->extend(Service::class, function($service) {
    return new DecoratedService($service);

Question: What is the make Method?
You may use the make method to resolve a class instance out of the container.
$api = $this->app->make("HelpSpot\API");

Question: What is Register Method?
within the register method, you should only bind things into the service container.

Question: What is the Boot Method?
if we need to register a view composer within our service provider? This should be done within the boot method.

Question: Where do you regiser service providers?
config/app.php configuration file

Question: What are Laravel’s Contracts?
Laravel’s Contracts are a set of interfaces that define the core services provided by the framework.

Question: Give example of Router?
Route::get("foo", function () {
return "Hello World";

Question: What are the available Router Methods?
Route::get($uri, $callback);
Route::post($uri, $callback);
Route::put($uri, $callback);
Route::patch($uri, $callback);
Route::delete($uri, $callback);
Route::options($uri, $callback);

Question: How to 301 redirect in laravel (permanent redirect)
Route::redirect("/old", "/new", 301);

Question: How to 302 redirectin laravel (temporary redirect)
Route::redirect("/old", "/new", 302);

Question: What are Middleware Groups?
Sometimes you may want to group several middleware under a single key to make them easier to assign to routes.

Question: What are Redirect responses?
Redirect responses are instances of the Illuminate\Http\RedirectResponse class, and contain the proper headers needed to redirect the user to another URL.

Question: Where do you locate database configuration file?
The database configuration for your application is located at config/database.php.

Question: What are Blade Templates?
Blade is the simple, yet powerful templating engine provided with Laravel.