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.


Wednesday 1 April 2020

Laravel interview questions for 2 year experienced

Laravel interview questions for 2 year experienced

Question: How to get current route name and method name?
request()->route()->getName(); //Return route name
request()->route()->getActionMethod();//Return method name



Question: What do you mean by bundles?
Bundles are referred to as packages in Laravel. These packages are used to increase the functionality of Laravel.


Question: Explain important directories used in a common Laravel application.?
App/ : This is a source folder where our application code lives. All controllers, policies, and models are in this folder.
Config/ : Here are configuration files.
Database/: Houses the database files, including migrations, seeds, and test factories.
Public/: Publicly accessible folder holding compiled assets and of course an index.php file.


Question: Explain reverse routing in Laravel.
Reverse routing is a method of generating URL based on symbol or name. It makes your Laravel application flexible.


Question: Define Lumen?
Lumen framework is a smaller, and faster, version of a building Laravel based services, and REST API's.


Question: How can you generate URLs?
Laravel has helpers to generate URLs.


Question: Explain faker in Laravel?
It is a type of module or packages which are used to create fake data. This data can be used for testing purpose.


Question: List basic concepts in Laravel?
  1. Routing
  2. Eloquent ORM
  3. Middleware
  4. Security
  5. Caching
  6. Blade Templating



Question: What is Eloquent?
Eloquent is an ORM used in Laravel. It provides simple active record implementation working with the database.


Question: What is the use of DB facade?
DB facade is used to run SQL queries like create, select, update, insert, and delete.


Question: What is a session in Laravel?
Session is used to pass user information from one web page to another.
Support for cookie, array, file, Memcached, and Redis to handle session data.


Question: Explain to listeners?
Listeners are used to handling events and exceptions.


Question: What are policies classes?
Policies classes include authorization logic of Laravel application.


Question: What is an Observer? Observeris used to make clusters of event listeners for a model.
Method names of these classes depict the Eloquent event. Observers classes methods receive the model as an argument.

Question: What is the use of the bootstrap directory?
It is used to initialize a Laravel project. This bootstrap directory contains app.php file.


Question: Where will you define Laravel's Facades?
In Illuminate\Support\Facades namespace.


Question: Name databases supported by Laravel.
  1. MySQL
  2. SQLite
  3. SQL Server
  4. PostgreSQL



Question: What is the default session timeout duration?
2 hours.


Question: How to remove a complied class file?
Use clear-compiled command.


Question: In which folder robot.txt is placed?
Robot.txt file is placed in Public directory.