Home > PHP Framework > Laravel > Summarize and organize common laravel interview questions

Summarize and organize common laravel interview questions

WBOY
Release: 2022-04-08 12:51:43
forward
3630 people have browsed it

This article brings you relevant knowledge about laravel, which mainly summarizes the most common laravel interviewers so that rookies and experienced candidates can find suitable jobs. I hope it will be helpful to everyone helpful.

Summarize and organize common laravel interview questions

[Related recommendations: laravel video tutorial]

The following are frequently asked Laravel and PHP related interview questions, so that Rookies as well as experienced candidates find suitable jobs.

Wish you all the best to find your ideal job soon! !

Learning is the ladder of human progress!!!

1) What is Laravel?

Laravel is an open source, widely used PHP framework . The platform is primarily used for developing web applications utilizing the MVC architectural pattern. Laravel is released under the MIT license.

Therefore, its source code is hosted on GitHub. It follows solid and accurate language rules, making it a reliable PHP framework.

2) Define Composer.

It is an application-level package manager for PHP. It provides a standard format for managing PHP software dependencies and libraries.

3) What is HTTP middleware?

HTTP middleware is a technology used to filter HTTP requests. Laravel includes a middleware that checks if the application user is authenticated.

4) The method names of the aggregation query builder

The aggregation methods of the query builder are: 1) max (), 2) min (), 3) sum (), 4) avg () and 5) count ().

5) What is Route?

A route is basically an endpoint specified by a URI (Uniform Resource Identifier). It acts as a pointer in Laravel applications.

Most commonly, a route points to a method on the controller and also indicates which HTTP methods can access the URI.

6) Why use Route?

Routes are stored in files in the /routes folder in the project root directory. By default, there are several different files corresponding to different "faces" of the application (the "faces" come from the Hexagonal Architecture approach).

8) Explain the important directories used in universal Laravel applications.

The common directories used in Laravel applications are:

  • App/: This is the source folder where our application code is located. All controllers, strategies and models are in this folder.
  • Config/: Save the application configuration file. These are usually not modified directly but depend on values ​​set in the .env (environment) file in the application root.
  • Database/: Stores database files, including migration, data filling, and test factory.
  • Public/: A publicly accessible folder that contains compiled resources and of course the index.php file.

9) What is a Controller?

The controller is the "MVC" (Model-View-Controller) architecture on which Laravel is based. C".

10) Explain reverse routing in Laravel.

Reverse routing is a method of generating URLs based on symbols or names. It makes your Laravel application flexible.

12) Explain the characteristics of traits in Laravel.

Laravel traits are a set of functions contained within another class. A trait is like an abstract class. You cannot instantiate it directly, but you can try its methods in other classes.

13) Explain the concept of contracts in Laravel.

They are a collection of interfaces for the Laravel framework. These contracts provide core services. Contracts in Laravel include corresponding framework implementations.

14) How to register your service provider?

You can register a service provider in the config/app.php configuration file, which contains an array in which you can configure the class name of the service provider.

15) How to define Laravel’s facade?

All facades are defined in the Illuminate\Support\Facades namespace.

16) Explain the difference between get and post

The Get method allows a limited amount of data to be sent in the request header. Post allows sending large amounts of data in the body.

17) List the packages in Laravel 5.6

The default packages in Laravel 5.6 are:
1) Envoy, 2) Passport, 3) Socialite, 4) Cashier, 5) Horizon, 6) Scout.

18) What is the service container in Laravel

The service container is used to execute in Laravel Dependency injection tools.

19) How to enable query log in Laravel?

You can enable query logging in Laravel using the enableQueryLog method.

20) Explain the concept of events in Laravel.

An event is an action or operation that helps you subscribe and listen to events that occur in your Laravel application. Laravel automatically fires certain events when any activity occurs.

21) Let’s talk about dependency injection and types of dependency injection.

It is the technology of ‘one object depends on another object’.
There are three types of dependency injection:

  1. Constructor injection
  2. setter injection
  3. Interface injection.

22) Are there any advantages to using laravel?

The following are the main advantages of laravel:

  • Laravel has a blade template engine that can create dynamic layouts and add compilation tasks.
  • It can be very simple Reuse code.
  • You don’t need to manually maintain and include paths because Laravel has autoloading capabilities.
  • The framework helps you make new tools using LOC containers.
  • Laravel provides a version control system that helps simplify migration management.

23) Explain the concept of validation in Laravel.

When designing any Laravel application , verification is an important concept. It ensures that the data is always in the expected format before it is stored in the database. Laravel provides several methods for validating data.
The base controller feature is the use of the ValidatesRequests class, which provides a useful way to validate requests from client computers.

24) What does ORM stand for?

ORM stands for Object Relational Mapping

25) How to reduce memory usage in Laravel?

When processing large amounts of data, you can use the cursor method to reduce memory usage

26) List the relationship types available in Laravel Eloquent.

The relationship types available in Laravel Eloquent are:

  1. One-to-one
  2. One-to-many
  3. Many-to-many
  4. Many-to-many association hasManyThrough
  5. Polymorphic relationship

27) Define the template engine used by Laravel.

Blade Is a powerful template engine used by Laravel.

28) List the databases supported by Laravel.

Laravel supports the following databases:

  • PostgreSQL
  • SQL Server
  • SQLite
  • MySQL

29) Why is migration important?

Migration is important because it allows you to share applications by maintaining database consistency.
It is difficult to share any Laravel application without migration.
It also allows you to synchronize your database.

30) Definition of Lumen

Lumen is a micro-framework. It is a smaller, faster version based on Laravel services and REST API.

31) Explanation PHP artisan

artisan is a command line tool for Laravel. It provides commands to help you build Laravel applications easily.

32) How to generate a link?

Laravel uses helpers functions to generate links. This is helpful when you establish links in templates and API responses.

33) Which class is used to handle exceptions?

Laravel exceptions are handled by the App.exceptions.handler class.

34) What are common HTTP error codes?

The most common HTTP error codes are:

- Error 404 – Displayed when page not found.
- Error - 401 – Unauthorized error shown when

35) Explain Fluent Query Builder in Laravel.

It is a database query generator that provides a convenient and fast interface to create and run database queries.

36) What is the purpose of the dd () function?

This function is used to print the contents of the variable to the browser. The full form of dd is Dump and Die.

37) List common artisan commands used in Laravel.

Laravel supports the following artisan commands:

  • PHP artisan down;

  • PHP artisan up;

  • PHP artisan make:controller;

  • PHP artisan make:model;

  • PHP artisan make:migration;

  • PHP artisan make: middleware;

#38) How to configure email sending in Laravel?

Laravel provides APIs to send emails locally and on live servers.

39) Explain Authorization

This is a method of using a password to identify a user's login credentials. In Laravel, it can be managed using a session with two parameters 1) username and 2) password.

40) delete (): Delete all records from the database table

-delete (): Delete all records from the database table.
-softDeletes (): Will not delete data from the table. It is used to mark any record as deleted.

41) How to make a live sitemap.xml file in Laravel?

You can create all of your website’s pages to tell search engines about your organization’s content. The search engine's crawler intelligently reads this file to crawl the site.

42) Explanation of faker in Laravel.

It is a module or package used to create fake data. This data can be used for testing purposes

It can also be used to generate:

  • Number

  • Address

  • DateTime

  • Payment

  • Lorem text.

  • How would you check if the table exists in the database?

Use the hasTable () function in Laravel to check if the required table exists in the database.

44) What are the significant differences between insert () and insertGetId () functions in Laravel?

Insert (): This function is only used to insert records into the database. Does not return auto-incrementing ID
InsertGetId (): This function inserts a record into the table, but is used when the ID field is auto-incrementing. (Insert the record and return the incremented ID)

45) Explanation of active record in Laravel - active record

In active record, the class maps to your Database Table. It helps you handle CRUD operations.

46) List the basic concepts in Laravel

The following are the basic concepts used in laravel:

  • Routing
  • Eloquent ORM
  • Middleware
  • Security
  • Cache
  • Blade Template

47) Definition Implicit controller.

Implicit controllers help you define appropriate routes to handle controller actions. You can define them in route.php file using Route::controller () method.

48) How to customize table name in Laravel model?

Customize the table name, you can override the value of the protected variable $table.

49) What is MVC framework?

It is Model, View and Controller:

Model: Model defines the logic for writing Laravel applications.
View: It covers the UI logic of a Laravel application.
Controller: It is the interface between model and view. This is a way for users to interact with the application.

50) Define @include.

@include to load multiple template view files. It helps you include a view within another view. Users can also load multiple files in one view.

51) Explain the concept of cookies.

Cookies are small files sent from a specific website and stored on the PC by the user's browser while the user is browsing .

52) Which file is used to establish a connection to the database?

To create a connection to the database, you can use an .env file.

53) What is Eloquent?

Eloquent is an ORM used in laravel. It provides a simple active record implementation for use with the database. Every database table has its model, which is used to interact with the table.

54) List some of Laravel’s built-in authentication controllers.

Laravel installations have a set of built-in universal authentication controllers. These controllers are:

RegisterController
LoginController
ResetPasswordController
ForgetPasswordController

55) Explain Laravel guard.

Laravel Guard is a special component for finding authenticated users.
Incoming routes for requests are initially routed through this guard to validate user-entered credentials. Guards are defined in the ../config/auth.php file.

56) What is Laravel API throttling?

This is the function of Laravel. It provides current limiting processing function. Throttling helps Laravel developers develop secure applications and prevent DOS attacks.

57) Explanation of collections in laravel Collections.

Collections are wrapper classes for arrays. Laravel Eloquent's queries use a set of the most commonly used functions to return database results.

58) What is the purpose of DB Facade?

DB Facade is used to run SQL queries such as create, query, update, insert and delete.

59) What is the purpose of object relational mapping?

Object-relational mapping is a technique that helps developers address, access, and manipulate objects without considering the relationship between the objects and their data sources.

60) Explain the concept of routing in Laravel.

It allows routing all your application requests to the controller. Laravel routing acknowledges and accepts Uniform Resource Identifiers with closures.

61) What is Ajax in Laravel?

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

62) What is session in Laravel?

session is used to pass user information from one web page to another. Laravel provides various drivers (such as cookies, arrays, files, Memcached and Redis) to handle session data.

63) How to access session session data?

Session data can be accessed by creating an instance of the session in an HTTP request. After getting the instance, use the get () method with "Key" as parameter to get the session details.

64) Explain the difference between authentication and authorization.

Authentication refers to confirming a user's identity through credentials, while authorization refers to gathering access rights to a system.

65) Explain listeners - listeners.

Listeners - listeners are used to handle events and exceptions. The most common listener for login events in Laravel is LoginListener.

66) What strategy class?

The policy class contains the authorization logic for the Laravel application. These classes are used for specific models or resources.

67) How to roll back the last migration?

You need to use the artisan command to roll back the previous migration.

68) What do you mean by Laravel Dusk?

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

69) Explanation of Laravel echo.

It is a JavaScript library that can subscribe to and listen to channel Laravel events. You can install echo using the NPM package manager.

70) What is the make method?

Laravel developers can use the make method to bind interfaces to create classes. This method returns an instance of a class or interface. Laravel automatically injects dependencies defined in the class constructor.

71) Explain Response in Laravel.

All controllers and routes should return responses before sending them back to the web browser. Laravel provides several methods for returning this response. The most basic response is to return a string from a controller or route.

72) ) What is query scope?

One of the features of Laravel is that we can reuse similar queries. We don't need to write the same type of query again in our Laravel project. After defining the scope, just call the scope method when querying the model.

73) Explain homestead in Laravel.

Laravel homestead is the official, one-time, pre-packaged vagrant box with a powerful development environment that eliminates the need to install HHVM, a web server and PHP on your computer.

74) What are namespaces in Laravel?

Namespaces allow users to group functions, classes, and constants with specific names.

76) Explain the difference between CodeIgniter and Laravel.

Parameter CodeIgniter Laravel
Support ORM Does not support object relational mapping. Supports ORM.
Provides authentication Does provide user authentication Has built-in user authentication
Programming paradigm Component-oriented Object-oriented
Yes Support for other databases Supports Microsoft SQL Server, ORACLE, MYSQL, IBM DB2, PostgreSQL, JDBC and orientDB compatible It supports PostgreSQL, MySQL, MongoDB and Microsoft BI, but CodeIgniter also supports others Databases, such as Microsoft SQL Server, DB2, Oracle, etc.
HTTPS support CodeIgniter partially supports HTTPS. Therefore, programmers can use URLs to protect the data transfer process by creating PATS Laravel supports custom HTTPS routing. Programmers can create specific URLs for HTTPS routes they define.

77) What are Observers?

Model Observers are a feature of Laravel. It is used to establish a cluster of event listeners for a model. The method names of these classes describe Eloquent events. Observers class methods receive models as parameters.

78) What is the purpose of bootstrap directory?

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

79) What is the default session timeout?

The default timeout for a Laravel session is 2 hours.

80) How to delete compiled class files?

Use the clear-compiled command to delete compiled class files.

81) In which folder is robot.txt placed?

Robot.txt file is placed in the “Public” directory.

82) Explain API.PHP routing.

The route corresponds to the API cluster. It has API middleware enabled by default in Laravel. These routes do not have any state or cross-request memory, nor do they have sessions.

83) What is defined route?

Defining routing is a method of generating routing paths. Links to these routes can be specified in the define route method

84) What is open source software?

Open source software is software whose source code is available for free. The source code can be shared and modified according to user requirements.

85) Explain Loggin in Laravel.

It is a technology that generates system error logs. Loggin helps improve system reliability. Laravel supports various logging modes such as syslog, daily, single and error logging modes.

86) What is localization?

One of the features of Laravel is support for various languages ​​used in applications. Developers can store strings for different languages ​​in files, which are stored in the resources/views folder. Developers should create a separate folder for each supported language.

87) Define hashing in Laravel.

This is the way to convert text into a key that displays the original text. Laravel uses the Hash facade to securely store passwords in hashed form.

88) Explain the concepts of encryption and decryption in Laravel.

Encryption is the process of transforming any information using certain algorithms in a way that makes it unreadable by a third user . Encryption protects your sensitive information from intruders.

Perform encryption using the encryption process. The message to be encrypted is called a plain message. The message obtained after encryption is called a cipher message. When ciphertext is converted into plain text or message, this process is called decryption.

89) How to share data with views?

To pass data to all views in Laravel, use a method called share(). This method takes two parameters, key and value.
Typically, the share () method is called from the boot method of the Laravel application service provider. Developers can use any service provider, AppServiceProvider or our own service provider.

90) Explain the web.php route.

Web.php is based on the public "browser" route. This is the most common route and is the problem experienced by web browsers. They traverse the web middleware group, also contain CSRF protection tools (helping defend against form-based malicious attacks and hacking), and usually contain some degree of "state" (I mean they leverage sessions).

91) How to generate requests in Laravel?

Use the following artisan command in Laravel to generate a request:

php artisan make:request UploadFileRequest
Copy after login

[Related recommendations: laravel video tutorial]

The above is the detailed content of Summarize and organize common laravel interview questions. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template