Saturday, 28 March 2020

Laravel Interview Questions and answers

Laravel Interview Questions and answers

Question: What is Laravel?
Laravel is a free and open-source PHP framework that follows the model–view–controller design pattern.

Question: What is the latest version of Laravel?
7.0, released on 3rd March 2020.

Question: Who created Laravel?
Taylor Otwell

Question: Who created Laravel?
Taylor Otwell

Question: What language does Laravel use?

Question: Which is the best IDE for Laravel?
Sublime Text

Question: Features of Laravel?
  1. Eloquent ORM
  2. Reverse routing
  3. Restful controllers
  4. Migrations
  5. Unit testing
  6. Automatic pagination
  7. Database Seeding
  8. Query builder available

Question: What are the new features of Laravel 7?
Laravel 7.0 is incorporated features such as Better routing speed, Laravel Airlock, Custom Eloquent casts, Fluent string operations, CORS support, and many more features like below.
  1. Custom Eloquent Casts
  2. Route Caching Speed Improvements
  3. HTTP Client
  4. Query Time Casts
  5. Blade Component Tags & Improvements
  6. Laravel Airlock
  7. CORS Support
  8. Fluent string operations
  9. Multiple Mail Drivers
  10. New Artisan Commands etc

Question: How to extend login expire time in Auth?
Open config\session.php file and add/update following key's value.
'lifetime' => 180

Question: What is middleware in Laravel?
Middleware operates as a bridge and filtering mechanism between a request and response.

Question: How to pass CSRF token with ajax request?
In between head, tag put
[meta name="csrf-token" content="{{ csrf_token() }}"]

In Ajax, we have to add
   headers: {
     'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')

Question: What is laravel Service container?
Service Container is a powerful tool which is used to manage class dependencies and perform dependency injection. Also known as the IoC container.

Question: How to use session in laravel?
Retrieving Data from session

Retrieving All session data

Remove data from session

Storing Data in session
session()->put('key', 'value');