Table of Contents

What is a session in Laravel?

Session is used to pass user information from one web page to another. Laravel provides various drivers like a cookie, array, file, Memcached, and Redis to handle session data.

What is Ajax in Laravel?

Ajax stands for Asynchronous JavaScript and XML is a web development technique that is used to create asynchronous Web applications. In Laravel, response() and json() functions are used to create asynchronous web applications.

Explain the concept of routing in Laravel?

It allows routing all your application requests to the controller. Laravel routing acknowledges and accepts a Uniform Resource Identifier with a closure.

What is the use of Object Relational Mapping?

Object Relational Mapping is a technique that helps developers to address, access, and manipulate objects without considering the relation between object and their data sources.

What is the use of DB facade?

DB facade is used to run SQL queries like create, select, update, insert, and delete.

Explain collections in Laravel?

Collections is a wrapper class to work with arrays. Laravel Eloquent queries use a set of the most common functions to return database result.

What is Laravel API rate limit?

It is a feature of Laravel. It provides handle throttling. Rate limiting helps Laravel developers to develop a secure application and prevent DOS attacks.

Define Laravel guard?

Laravel guard is a special component that is used to find authenticated users. The incoming requested is initially routed through this guard to validate credentials entered by users. Guards are defined in ../config/auth.php file.

Name some Inbuilt Authentication Controllers of Laravel?

Laravel installation has an inbuilt set of common authentication controllers. These controllers are:

<> RegisterController
<> LoginController
<> ResetPasswordController
<> ForgetPasswordController

What is Eloquent?

Eloquent is an ORM used in Laravel. It provides simple active record implementation working with the database. Each database table has its Model, which used to interact with the table.

Explain Response in Laravel?

All controllers and routes should return a response to be sent back to the web browser. Laravel provides various ways to return this response. The most basic response is returning a string from controller or route.

What is make method?

Laravel developers can use make method to bind an interface to concreate class. This method returns an instance of the class or interface. Laravel automatically inject dependencies defined in class constructor.

Explain Laravel echo?

It is a JavaScript library that makes possible to subscribe and listen to channels Laravel events. You can use NPM package manager to install echo.

What do you mean by Laravel Dusk?

Laravel Dusk is a tool which is used for testing JavaScript enabled applications. It provides powerful, browser automation, and testing API.

List some Aggregates methods provided by query builder in Laravel ?

count()
max()
min()
avg()
sum()

What is the use of dd() in Laravel?

In Laravel, dd() is a helper function used to dump a variable’s contents to the browser and stop the further script execution. It stands for Dump and Die. It is used to dump the variable/object and then die the script execution. You can also isolate this function in a reusable functions file or a Class.

What is the Laravel Cursor?

The cursor method in the Laravel is used to iterate the database records using a cursor. It will only execute a single query through the records. This method is used to reduce the memory usage when processing through a large amount of data.

Example of Laravel Cursor

foreach (Product::where(‘name’, ‘Bob’)->cursor() as $fname) {
//do some stuff
}

What is Laravel nova?

Laravel Nova is an admin panel by laravel ecosystem. It easy to install and maintain. Laravel Nova comes with features that have ability to administer our database records using Eloquent.

How to clear Cache in Laravel?

You can use php artisan cache:clear commnad to clear Cache in Laravel.

What is yield in Laravel?

In Laravel, @yield is principally used to define a section in a layout and is constantly used to get content from a child page unto a master page. So, when the Laravel performs blade file, it first verifies if you have extended a master layout, if you have extended one, then it moves to the master layout and commences getting the @sections.

What is Laravel Vapor?

It is a serverless deployment platform that is powered by AWS.Laravel Vapor provides on-demand auto-scaling with zero server maintenance.

What is Laravel Forge?

Laravel Forge helps in organizing and designing a web application. Although the manufacturers of the Laravel framework developed this toll, it can automate the deployment of every web application that works on a PHP server.

What is namespace in Laravel?

A namespace allows a user to group the functions, classes, and constants under a specific name.

How to generate a request in Laravel?

Use the following artisan command in Laravel to generate request:

php artisan make:request UploadFileRequest

Explain the concept of encryption and decryption in Laravel?

It is a process of transforming any message using some algorithms in such way that the third user cannot read information. Encryption is quite helpful to protect your sensitive information from an intruder.

Encryption is performed using a Cryptography process. The message which is to be encrypted called as a plain message. The message obtained after the encryption is referred to as cipher message. When you convert cipher text to plain text or message, this process is called as decryption.

Define hashing in Laravel?

It is the method of converting text into a key that shows the original text. Laravel uses the Hash facade to store the password securely in a hashed manner.

What is yield in Laravel?

In Laravel, @yield is principally used to define a section in a layout and is constantly used to get content from a child page unto a master page. So, when the Laravel performs blade file, it first verifies if you have extended a master layout, if you have extended one, then it moves to the master layout and commences getting the @sections.

In which folder robot.txt is placed?

Robot.txt file is placed in Public directory.

How to remove a complied class file?

Use clear-compiled command to remove the compiled class file.

What is the default session timeout duration?

The default Laravel session timeout duration is 2 hours.

What is the use of the bootstrap directory?

It is used to initialize a Laravel project. This bootstrap directory contains app.php file that is responsible for bootstrapping the framework.

What is an Observer?

Model Observers is a feature of Laravel. It is 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.

What is query scope?

It is a feature of Laravel where we can reuse similar queries. We do not require to write the same types of queries again in the Laravel project. Once the scope is defined, just call the scope method when querying the model.

How to rollback last migration?

Use need to use artisan command to rollback the last migration.

What are policies classes?

Policies classes include authorization logic of Laravel application. These classes are used for a particular model or resource.

Provide System requirements for installation of Laravel framework ?

In order to install Laravel, make sure your server meets the following requirements:

  • PHP >= 7.1.3
  • OpenSSL PHP Extension
  • PDO PHP Extension
  • Mbstring PHP Extension
  • Tokenizer PHP Extension
  • XML PHP Extension
  • Ctype PHP Extension
  • JSON PHP Extension

Why are migrations necessary?

Migrations are necessary because:

  • Without migrations, database consistency when sharing an app is almost impossible, especially as more and more people collaborate on the web app.
  • Your production database needs to be synced as well.

List types of relationships available in Laravel Eloquent?

Below are types of relationships supported by Laravel Eloquent ORM.

  • <> One To One
  • <> One To Many
  • <> One To Many (Inverse)
  • <> Many To Many
  • <> Has Many Through
  • <> Polymorphic Relations
  • <> Many To Many Polymorphic Relations

How to use custom table in Laravel Modal ?

You can use custom table in Laravel by overriding protected $table property of Eloquent.

Below is sample uses

class User extends Eloquent{
protected $table=”my_user_table”;

}

Explain Bundles in Laravel?

In Laravel, bundles are also called packages. Packages are the primary way to extend the functionality of Laravel. Packages might be anything from a great way to work with dates like Carbon, or an entire BDD testing framework like Behat.In Laravel, you can create your custom packages too.

What is Lumen?

Lumen is PHP micro-framework that built on Laravel’s top components.It is created by Taylor Otwell. It is perfect option for building Laravel based micro-services and fast REST API’s. It’s one of the fastest micro-frameworks available.
You can install Lumen using composer by running below command

composer create-project –prefer-dist laravel/lumen blog

Explain Laravel’s Middleware?

As the name suggests, Middleware acts as a middleman between request and response. It is a type of filtering mechanism. For example, Laravel includes a middleware that verifies whether the user of the application is authenticated or not. If the user is authenticated, he will be redirected to the home page otherwise, he will be redirected to the login page.

Does Laravel support caching?

Yes, Laravel supports popular caching backends like Memcached and Redis.
By default, Laravel is configured to use the file cache driver, which stores the serialized, cached objects in the file system.For large projects, it is recommended to use Memcached or Redis.

Explain to listeners?

Listeners are used to handling events and exceptions. The most common listener in Laravel for login event is LoginListener.

State the difference between authentication and authorization?

Authentication means confirming user identities through credentials, while authorization refers to gathering access to the system.

How to access session data?

Session data be access by creating an instance of the session in HTTP request. Once you get the instance, use get() method with a “Key” as a parameter to get the session details.

How to check request is ajax or not ?

In Laravel, we can use $request->ajax() method to check request is ajax or not.

Example:

public function saveData(Request $request)
{
if($request->ajax()){
return “Request is of Ajax Type”;
}
return “Request is of Http type”;
}

What is reverse routing in Laravel?

Laravel reverse routing is generating URL’s based on route declarations. Reverse routing makes your application so much more flexible. It defines a relationship between links and Laravel routes. When a link is created by using names of existing routes, appropriate Uri’s are created automatically by Laravel. Here is an example of reverse routing.

// route declaration

Route::get(‘login’, ‘users@login’);
Using reverse routing we can create a link to it and pass in any parameters that we have defined. Optional parameters, if not supplied, are removed from the generated link.

{{ HTML::link_to_action(‘users@login’) }}
It will automatically generate an Url like http://xyz.com/login in view.

How to enable query log in Laravel ?

Use the enableQueryLog method to enable query log in Laravel

DB::connection()->enableQueryLog();
You can get array of the executed queries by using getQueryLog method:
$queries = DB::getQueryLog();

What are Laravel eloquent?

Laravel’s Eloquent ORM is simple Active Record implementation for working with your database. Laravel provide many different ways to interact with your database, Eloquent is most notable of them. Each database table has a corresponding “Model” which is used to interact with that table. Models allow you to query for data in your tables, as well as insert new records into the table.

Below is sample usage for querying and inserting new records in Database with Eloquent.

// Querying or finding records from products table where tag is ‘new’
$products= Product::where(‘tag’,’new’);
// Inserting new record
$product =new Product;
$product->title=”Iphone 7″;
$product->price=”$700″;
$product->tag=’iphone’;
$product->save();

Related Topic :

To Play Quiz Online

What is LibreOffice? LibreOffice Impress Features ?

LibreOffice Impress CCC Questions and Answer in Hindi 2022

CCC LibreOffice Calc Paper Questions with Answers

[social_share_button themes='theme1']

Leave a Comment