0% found this document useful (0 votes)
15 views

Unit 1 Laravel

This document provides details about a course on Full-Stack Web Development using Laravel with Vue.JS. It includes information about the course instructor, syllabus, evaluation scheme, course objectives, outcomes and their mappings to program outcomes and objectives.

Uploaded by

nitor29306
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Unit 1 Laravel

This document provides details about a course on Full-Stack Web Development using Laravel with Vue.JS. It includes information about the course instructor, syllabus, evaluation scheme, course objectives, outcomes and their mappings to program outcomes and objectives.

Uploaded by

nitor29306
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 125

Noida Institute of Engineering and Technology, Greater Noida

Full-Stack Web Development using Laravel with


Vue.JS

Unit: I

Introduction to Laravel
Rajat Kumar
Course Details (Asst. Professor)
(B. Tech. 6th Sem) CSE Department

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 1


Brief Introduction of Faculty

COURSE BOARD/UNIVERSITY YEAR OF PASSING

M.Tech ITM, AKTU, Lucknow 2020

B.Tech ITM, AKTU, Lucknow 2016

• Certificate of Recognition for role as Faculty in MOOCs Course


Python/CSS from E & ICT Academy, IIT Kanpur.
• Worked on Internet of things (IoT) technology under the topic Energy
efficient technique for data aggregation in M.Tech.
• Published paper in International journal of research in electronics and
computer engineering (IJRECE) on “Energy efficient technique for data
aggregation in IoT” (April-June 2019).
• Area of Interest: FullStack Development, Machine Learning, IOT

Rajat Kumar Laravel with Vue.js Unit 5

2/15/2024 2
Evaluation Scheme

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 3


Syllabus
UNIT-I: Introduction to Laravel

Introduction to Laravel, Laravel Features, Laravel installation,


Application Structure of Laravel, Root Directory, App Directory, Basic
Configuration, Environmental Configuration, Routing, Routing
Parameters, Middleware, Terminable Middleware, Middleware
Parameter, Controllers, Restful Resource Controllers, Implicit
Controllers, Constructor Injection, Method Injection, Laravel Sail,
Laravel Jetstream.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 Unit I 4
Syllabus

UNIT-II: Vue.js Framework&Inertia.js

Vue.js Template Syntax And Expressions, Vue directives, loops and


conditional rendering, VueDevtools, Handling user Inputs, Handling
Events, Vuejs Methods and Computed Properties, Attribute Bindings
and dynamic classes, Concepts of Inertia.js, How it works, Inertia
protocol, Routing, Responses and Pages, Creating links, GET,
POST,PUT, PATCH, and DELETE method in Inertia.js

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 5


Syllabus

UNIT-III: Laravel Authentication&Laravel Faker

Laravel design patter, Laravel blade template engine, Artisan command,


Login with username or email, Register with username or email, Logout,
Validate request data (required, unique, etc..), Protecting Router,
Password Confirmation, Social & Other Authentication method, Show
success / Failure message, Faker PHP library, Create data seeder, Seed
data, Localisation, Model Factories

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 Unit I 6
Syllabus

UNIT-IV: Connecting Laravel with databases

Database Configuration File, Read/Write connections, Running A


Select Query, Running an Insert, Update, Delete Statement,
Listening For Query Events, Database Transaction, rollback and
commit method, Accessing connections, Query Logging, Laravel
Query Builder & ORM, Laravel Migration& Eloquent.

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js 7


Unit I
Syllabus

UNIT-V: Deployment Laravel application to production

PHPExtension:BCMath,Ctype,cURL,JSON,Mbstring,OpenSSL,PCRE,
PDOServer Configuration, Nginx, Laravel server management
service LaravelForge, Autoloader optimization, Optimizing
Configuration Loading, Optimizing Route Loading, Optimizing
View Loading, Debug Mode, Deploying With Vapor.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 Unit I 8
Branch Wise Application

Adaptability: It gives bother free migration, basic, and efficient structure.

Components: They help in creating custom elements that can be reused in


HTML.

Transition: Various methodologies are given in Vue.js to apply a transition to


HTML components when they are included or expelled from the DOM.

Detailed Documentation: It gives a simple learning curve through point-by-


point documentation

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 9


Course Objective

1.Laravel Development Means Faster Time-To-Market. ...

2.Better Authentication and Authorization Option. ...

3.Stay Away from Technical Vulnerabilities with Laravel Framework. ...

4.MVC Architecture of Laravel Framework. ...

5.Automated and Unit Testing Feature. ...

6.Automated Task Execution and Scheduling

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 10


Course Outcomes (COs)

CO : 01. Apply the knowledge of PHP that are vital in understanding Laravel application
and analyze the concepts, principles and methods in current Server-side
technology to implement Laravel application over the web.
CO : 02. Explain, analyze and apply the role of Client-side scripting language like Vuejs in the
workings of the web and web applications.

CO : 03. Implementing and analyzing the concept of Larvel Faker and Authentication on
Laravel.

CO : 04. Understand the impact of web designing by database connectivity with different
databases in the current market place where everyone use to prefer electronic
medium for shoping, commerce, and even social life also.
CO : 05. Analyzing and Creating a functional website using Laravel and Vuejs and Deploying
and Optimizing Web Application using Forge / Vapor.

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 11


Program Outcomes (POs)

PO : 01. Engineering Knowledge


PO : 02. Problem Analysis
PO : 03. Design/Development of solutions
PO : 04. Conduct Investigations of complex problems
PO : 05. Modern tool usage
PO : 06. The engineer and society
PO : 07. Environment and sustainability
PO : 08. Ethics
PO : 09. Individual and teamwork
PO : 10. Communication
PO : 11. Project management and finance
PO : 12. Life-long learning

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 12


COs - POs Mapping

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 13


Program Specific Outcomes(PSOs)

Sr. No. PSO Description

PSO1 Understand to shows relationships and interactions between classes or objects of a


pattern.
Study to speed up the development process by providing well-tested, proven
PSO2 development
Select a specific design pattern for the solution of a given design problem
PSO3

Create a catalogue entry for a simple design pattern whose purpose and application
PSO4 is understood.

Rajat Kumar Vue.js Framework & Inertia.js Unit I


2/15/2024 14
COs - PSOs Mapping

CO.K PSO1 PSO2 PSO3 PSO4

CO1 3 - - -

CO2 3 3 - -

CO3 3 3 - -

CO4 3 3 - -

CO5 3 3 - -

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 15


Program Educational Objectives (PEOs)

Sr. No. PEOs Description

To have an excellent scientific and engineering breadth so as to comprehend, analyze,


PEO 1 design and provide sustainable solutions for real-life problems using state-of-the-art
technologies.

To have a successful career in industries, to pursue higher studies or to support


PEO 2
entrepreneurial endeavors and to face the global challenges.
To have an effective communication skills, professional attitude, ethical values and a desire
PEO3 to learn specific knowledge in emerging trends, technologies for research, innovation and
product development and contribution to society.

To have life-long learning for up-skilling and re-skilling for successful professional career
PEO4
as engineer, scientist, entrepreneur and bureaucrat for betterment of society.

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 16


Pattern of Online External Exam Question Paper (100 marks)

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 17


Pattern of Online External Exam Question Paper (100 marks)

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 18


Pattern of Online External Exam Question Paper (100 marks)

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 19


Pattern of Online External Exam Question Paper (100 marks)

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 20


Pattern of Online External Exam Question Paper (100 marks)

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 21


Prerequisite and Recap

• Before begin progressing with this tutorial, we assume that we are familiar
with website development using PHP and MySQL also we should be
familiar with HTML, Core PHP, and Advance PHP. We have applied Laravel
version 5.1 in all the examples.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 22
Unit I
Brief Introduction about the Subject with videos

YouTube /other Video Links:

• https://www.youtube.com/watch?v=1onmPIe07yo&ab_channel=Bitfumes

• https://www.youtube.com/watch?v=AhM4nAxaTLo&ab_channel=StellaLi

• https://www.youtube.com/watch?v=AEVhRhD2Wk&ab_channel=MattSocha

• https://www.youtube.com/watch?v=DfslJ-kaZXA&ab_channel=GeekyShows

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 Unit I 23
Unit Content

• Introduction to Laravel, Laravel Features, Laravel installation, Application


Structure of Laravel, Root Directory, App Directory, Basic Configuration,
Environmental Configuration, Routing, Routing Parameters, Middleware,
Terminable Middleware, Middleware Parameter, Controllers, Restful
Resource Controllers, Implicit Controllers, Constructor Injection, Method
Injection, Laravel Sail, Laravel Jetstream.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 24
Unit I
Unit Objective

• In this unit we will learn basic of Laravel.


• Laravel attempts to take the pain out of development by easing common
tasks used in the majority of web projects, such as authentication, routing,
sessions, and caching.
• Laravel aims to make the development process a pleasing one for the
developer without sacrificing application functionality.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 25
Unit I
Topic Objective

• Topic :Introduction to Laravel


In this topic, the students will learn about the basic of Laravel. And also basic
of Laravel framework and MVC.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 26
Unit I
Introduction to Laravel

• Laravel is an open-source PHP framework. It also offers the rich set of


functionalities that incorporates the basic features of PHP frameworks such
as Codelgniter, and other programming languages like Ruby on Rails.
What is Laravel?
• Laravel is a PHP framework that uses the MVC architecture.
where,
• Framework: It is the collection of methods, classes, or files that the
programmer uses, and they can also extend its functionality by using their
code.
• Architecture: It is the specific design pattern that the framework follows.
Laravel is following the MVC architecture.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 27
Unit I
Laravel Features

• We know that PHP is the oldest programming language used by the


programmers, and more than 20 million websites are developed by using
PHP. PHP is a very suitable programming language as it satisfies the
business requirements whether the business is big or small. Laravel is one
of the most popular frameworks having a high rich set of functionalities.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 28
Unit I
Continue..

• Authentication
• User authentication is a common feature in web applications. Laravel eases designing
authentication as it includes features such as register, forgot password and send
password reminders.
• Innovative Template Engine
• Laravel provides an innovative template engine which allows the developers to create
the dynamic website. The available widgets in Laravel can be used to create solid
structures for an application.
• Effective ORM (Object Relational Mapper)
• Laravel contains an inbuilt ORM with easy PHP Active Record implementation. An
effective ORM allows the developers to query the database tables by using the simple
PHP syntax without writing any SQL code. It provides easy integration between the
developers and database tables by giving each of the tables with their corresponding
models.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 29
Unit I
Continue..

MVC Architecture Support


• Laravel supports MVC architecture. It provides faster development process as in
MVC; one programmer can work on the view while other is working on the
controller to create the business logic for the web application. It provides multiple
views for a model, and code duplication is also avoided as it separates the business
logic from the presentation logic.
Secure Migration System
• Laravel framework can expand the database without allowing the developers to put
much effort every time to make changes, and the migration process of Laravel is
very secure and full-proof. In the whole process, php code is used rather than SQL
code.
Unique Unit-testing
• Laravel provides a unique unit-testing. Laravel framework can run several test cases
to check whether the changes harm the web app or not. In Laravel, developers can
also write the test cases in their own code.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 30
Unit I
Continue..

Intact Security
• Application security is one of the most important factors in web application
development. While developing an application, a programmer needs to take
effective ways to secure the application. Laravel has an inbuilt web application
security, i.e., it itself takes care of the security of an application. It uses "Bcrypt
Hashing Algorithm" to generate the salted password means that the password is
saved as an encrypted password in a database, not in the form of a plain text.
Libraries and Modular
• Laravel is very popular as some Object-oriented libraries, and pre-installed libraries
are added in this framework, these pre-installed libraries are not added in
other php frameworks. One of the most popular libraries is an authentication
library that contains some useful features such as password reset, monitoring active
users, Bcrypt hashing, and CSRF (Cross-Site Request Forgery) protection. This
framework is divided into several modules that follow the php principles allowing
the developers to build responsive and modular apps

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 31
Unit I
Continue..

• Artisan
• Laravel framework provides a built-in tool for a command-line known as Artisan that
performs the repetitive programming tasks that do not allow the php developers to
perform manually. These artisans can also be used to create the skeleton code,
database structure, and their migration, so it makes it easy to manage the database
of the system. It also generates the MVC files through the command line. Artisan
also allows the developers to create their own commands.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 32
Unit I
Laravel installation

• For managing dependencies, Laravel uses composer. Make sure you have a
Composer installed on your system before you install Laravel. In this chapter, you
will see the installation process of Laravel.
• You will have to follow the steps given below for installing Laravel onto your
system −
• Step 1 − Visit the following URL and download composer to install it on your
system.
• https://getcomposer.org/download/
• Step 2 − After the Composer is installed, check the installation by typing the
Composer command in the command prompt as shown in the following
screenshot.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 33
Unit I
Laravel installation

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 34
Unit I
Laravel installation

• Step 3 − Create a new directory anywhere in your system for your new Laravel
project. After that, move to path where you have created the new directory and
type the following command there to install Laravel.

• composer create-project laravel/laravel –-prefer-dist


• Now, we will focus on installation of version 5.7. In Laravel version 5.7, you can
install the complete framework by typing the following command −

• composer create-project laravel/laravel test dev-develop


• The output of the command is as shown below −

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 35
Unit I
Laravel installation

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 36
Unit I
Laravel installation

• The Laravel framework can be directly installed with develop branch which includes
the latest framework.
• Step 4 − The above command will install Laravel in the current directory. Start the
Laravel service by executing the following command.
• php artisan serve
• Step 5 − After executing the above command, you will see a screen as shown below −

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 37
Unit I
Laravel installation

• Step 6 − Copy the URL underlined in gray in the above screenshot and open that
URL in the browser. If you see the following screen, it implies Laravel has been
installed successfully.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 38
Unit I
Topic objective

• Application Structure of Laravel


In this topic student will understand the structure of Laravel,
directory of Laravel and bootstrap directory.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 39
Unit I
Application Structure of Laravel

• The application structure in Laravel is basically the structure of folders, sub-


folders and files included in a project. Once we create a project in Laravel,
we get an overview of the application structure as shown in the image here.
• The snapshot shown here refers to the root folder of Laravel namely laravel-
project. It includes various sub-folders and files. The analysis of folders and
files, along with their functional aspects is given below −

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 40
Unit I
Root Directory

• Application Structure

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 41
Unit I
Continue..

• App
• It is the application folder and includes the entire source code of the project. It
contains events, exceptions and middleware declaration. The app folder comprises
various sub folders as explained below −
• Console
• Console includes the artisan commands necessary for Laravel. It includes a directory
named Commands, where all the commands are declared with the appropriate
signature. The file Kernal.php calls the commands declared in Inspire.php.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 42
Unit I
Continue..

• If we need to call a specific command in Laravel, then we should make appropriate


changes in this directory.

• Events
• This folder includes all the events for the project.

• Events
• Events are used to trigger activities, raise errors or necessary validations and
provide greater flexibility. Laravel keeps all the events under one directory. The
default file included is event.php where all the basic events are declared.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 43
Unit I
Continue..

• Laravel's app directory


• The app folder is one of the major folders in Laravel as most of the code is written
in the app folder. The App folder contains the following sub-folders:
• Console
• Exceptions
• Http
• Providers

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 44
Unit I
Continue..

• Console
• Console folder contains the artisan commands required for Laravel. It contains the
commands which are declared with the appropriate signature.
• Exceptions
• Exceptions folder contains the various exception handlers. It handles the exceptions
thrown by the Laravel project. The Exceptions directory contains the methods that
handle the exceptions.
• The Exceptions directory contains the file handle.php that handles all the exceptions.
• Http
• The http folder is a sub-folder of the app folder. It has sub-folders such as controllers,
middleware, and requests. Laravel follows the MVC architecture, so http includes
controllers, views, and requests.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 45
Unit I
Continue..

• Where,
• Middleware: It is a sub-folder of the http directory. It provides a filter mechanism
and communication between request and response.
• Requests: It is a sub-folder of http which includes all the requests of an application.
• Providers
• The Providers directory is used to contain all the service providers that are required
to register events for core servers and provides configuration for Laravel
application.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 46
Unit I
Continue..

• Laravel's bootstrap directory


• The bootstrap directory holds the files that are required to bootstrap the Laravel
application and to configure auto-loading. The bootstrap folder contains a sub-
folder cache used for caching a web application. It also contains the
file app.php that initializes the scripts required for bootstrap.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 47
Unit I
Continue..

• The above screen shows the structure of the bootstrap directory. It contains one
folder, i.e., cache and two files, app.php and autoload.php.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 48
Unit I
Continue..

• Laravel's config directory


• The config's directory contains the various configuration files required for the
Laravel application. Various files are available inside the config's directory shown in
the below screenshot, and each file performs their functionalities as per their
names.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 49
Unit I
Topic Objective

Topic :Basic Configuration


In this topic student will gain about basic configuration with Laravel and also
how environmental configuration works.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 50
Unit I
Basic Configuration

• All of the configuration files for the Laravel framework are stored in the config
directory. Each option is documented, so feel free to look through the files and get
familiar with the options available to you.
• These configuration files allow you to configure things like your database connection
information, your mail server information, as well as various other core
configuration values such as your application timezone and encryption key.
• Application Overview
• We can get a quick overview of your application's configuration, drivers, and
environment via the about Artisan command:

php artisan about

• If you're only interested in a particular section of the application overview output,


you may filter for that section using the --only option:

php artisan about --only=environment

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 51
Unit I
Environmental Configuration

Environment Configuration
• Environment Variable Types
• Retrieving Environment Configuration
• Determining The Current Environment
• Encrypting Environment Files

• Environment Configuration
• It is often helpful to have different configuration values based on the environment
where the application is running. For example, you may wish to use a different cache
driver locally than you do on your production server.
• To make this a effective, Laravel utilizes the DotEnv PHP library. In a fresh Laravel
installation, the root directory of your application will contain a .env.example file
that defines many common environment variables. During the Laravel installation
process, this file will automatically be copied to .env.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 52
Unit I
Continue..

• Environment Variable Types


• All variables in your .env files are typically parsed as strings, so some reserved
values have been created to allow you to return a wider range of types from the
env() function:
.env Value env() Value
true (bool) true
(true) (bool) true
false (bool) false
(false) (bool) false
empty (string) ''
(empty) (string) ''
null (null) null
(null) (null) null

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 53
Unit I
Continue..

• If you need to define an environment variable with a value that contains


spaces, you may do so by enclosing the value in double quotes:

APP_NAME="My Application"

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 54
Unit I
Continue..

• Retrieving Environment Configuration


• All of the variables listed in the .env file will be loaded into the $_ENV PHP
super-global when your application receives a request. However, you may
use the env function to retrieve values from these variables in your
configuration files. In fact, if you review the Laravel configuration files, you
will notice many of the options are already using this function:

'debug' => env('APP_DEBUG', false),

• The second value passed to the env function is the "default value". This
value will be returned if no environment variable exists for the given key.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 55
Unit I
Continue..

• Determining The Current Environment


• The current application environment is determined via the APP_ENV variable from your
.env file. You may access this value via the environment method on the App facade:

• use Illuminate\Support\Facades\App;

• $environment = App::environment();

• You may also pass arguments to the environment method to determine if the environment
matches a given value. The method will return true if the environment matches any of the
given values:

• if (App::environment('local')) {
• // The environment is local
• }

• if (App::environment(['local', 'staging'])) {
• // The environment is either local OR staging...
• }

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 56
Unit I
Continue..

• Encrypting Environment Files


• Unencrypted environment files should never be stored in source control.
However, Laravel allows you to encrypt your environment files so that they
may be safely be added to source control with the rest of your application.

• Encryption
• To encrypt an environment file, you may use the env:encrypt command:

• php artisan env:encrypt

• Running the env:encrypt command will encrypt your .env file and place the
encrypted contents in an .env.encrypted file. The decryption key is
presented in the output of the command and should be stored in a secure
password manager. If you would like to provide your own encryption key
you may use the --key option when invoking the command:

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 57
Unit I
Continue..

• php artisan env:encrypt --key=3UVsEgGVK36XN82KKeyLFMhvosbZN1aF

• The length of the key provided should match the key length required by the
encryption cipher being used. By default, Laravel will use the AES-256-CBC
cipher which requires a 32 character key. You are free to use any cipher
supported by Laravel's encrypter by passing the --cipher option when
invoking the command.

• If your application has multiple environment files, such as .env and


.env.staging, you may specify the environment file that should be encrypted
by providing the environment name via the --env option:

• php artisan env:encrypt --env=staging

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 58
Unit I
Topic Objective

Topic :Routing
Routing in Laravel allows the students to route all your application
requests to its appropriate controller.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 59
Unit I
Routing

Routing is one of the essential concepts in Laravel. The main functionality of the
routes is to route all your application requests to the appropriate controller.

Default Route files


All Laravel routes are defined inside the route files located in
the routes directory.
When we create a project, then a route directory is created inside the project.
The route/web.php directory contains the definition of route files for your web
interface.
The routes in web.php are assigned with the web middleware group that
provides the features like session state and CSRF protection.
The routes defined in routes/api.php are assigned with the API middleware
group, and they are stateless.

We will start by defining the routes in routes/web.api file.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 60
Unit I
Continue..

<?php
Route::get('/', function ()
{
return view ('welcome');
});

In the above case, Route is the class which defines the static method get().
The get() method contains the parameters '/' and function() closure. The '/'
defines the root directory and function() defines the functionality of the get()
method.

In the above route, the url is '/'; therefore, we entered


the localhost/laravelproject/public URL in the web browser.

As the method returns the view('welcome'), so the above output shows the
welcome view of the Laravel.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 61
Unit I
Continue..

<?php
Route::get('/example', function ()
{
return "Hello World";
});

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 62
Unit I
Continue..

• The routing mechanism is shown in the image given below −

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 63
Unit I
Continue..

• Let us now understand the steps involved in routing mechanism in detail −


• Step 1 − Initially, we should execute the root URL of the application.
• Step 2 − Now, the executed URL should match with the appropriate method in
the route.php file. In the present case, it should match the method and the root (‘/’) URL.
This will execute the related function.
• Step 3 − The function calls the template file resources/views/welcome.blade.php. Next,
the function calls the view() function with argument ‘welcome’ without using
the blade.php.
• This will produce the HTML output as shown in the image below −

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 64
Unit I
Routing Parameters

• There are two types of parameters we can use:


• Required Parameters
• Optional Parameters

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 65
Unit I
Continue..

• Required Parameters
• The required parameters are the parameters that we pass in the URL.
Sometimes you want to capture some segments of the URI then this can be
done by passing the parameters to the URL. For example, you want to
capture the user id from the URL.
<?php • Output
Route::get('/', function() • When we enter the URL "localhost/laravelproject/public/".
{
return "This is a home page";
}
);
Route::get('/about', function()
{
return "This is a about us page";
}
);
Route::get('/contact', function()
{
return "This is a contact us page";
}
);

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 66
Unit I
Continue..

• When we enter the URL "localhost/laravelproject/public/about".

• When we enter the URL "localhost/laravelproject/public/contact".

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 67
Unit I
Optional Parameters

• Suppose you want to specify the route parameter occasionally, in order to achieve
this, you can make the route parameter optional. To make the route parameter
optional, you can place '?' operator after the parameter name. If you want to
provide the optional parameter, and then make sure that you have also provided
the default value to the variable.

• Let's understand through some examples.


Example 1:
Route::get('user/{name?}', function ($name=null) {
return $name;
});

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 68
Unit I
Continue..

• When we do not pass any variable to the URL, then the output would be:

• When we pass 'akshita' in the URL, then the output would be:

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 69
Unit I
Continue..

• From the above outputs, we observe that the parameter we pass in the URL is
optional. As we have provided the default value to the parameter as Null, so if we
do not pass any parameter, it will return null. If we pass the parameter in the URL,
then the value of the parameter would be displayed.
Route::get('user/{name?}', function ($name = 'himani') {
return $name;
});
• In the above example, we have provided the default value as 'himani’.
• OUTPUT

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 70
Unit I
Middleware

Topic : Middleware
In this topic student understand that how Middleware provide a convenient
mechanism for inspecting and filtering HTTP requests entering your
application. For example, Laravel includes a middleware that verifies the user
of your application is authenticated.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 71
Unit I
Middleware

Middleware acts as a layer between the user and the request. It means that when
the user requests the server then the request will pass through the middleware,
and then the middleware verifies whether the request is authenticated or not. If
the user's request is authenticated then the request is sent to the backend. If the
user request is not authenticated, then the middleware will redirect the user to
the login screen.

An additional middleware can be used to perform a variety of tasks except for


authentication. For example, CORS (Cross Origin Resource Sharing) middleware is
responsible for adding headers to all the responses.

Laravel framework includes several middleware such as authentication and CSRF


protection, and all these are located in the app/Http/Middleware directory.
We can say that middleware is an http request filter where you can check the
conditions.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 72
Unit I
Middleware Parameters

In middleware, we are going to discuss the following topics:

• Make a middleware
• Apply middleware
• Check condition in middleware
• Route middleware

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 73
Unit I
Creating a Middleware

Type the command php artisan make:middleware 'name of the middleware'.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 74
Unit I
Creating a Middleware

In the above screen, we type the command "php artisan


make:middleware CheckAge" where CheckAge is the name of the
middleware. The above window shows that the middleware has been
created successfully with the name "CheckAge".

To see whether the CheckAge middleware is created or not, go to your


project. Our project name is laravelproject, so the path for the middleware
would be: C:\xampp\htdocs\laravelproject\app\Http\Middleware.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 75
Unit I
Apply a Middleware

Middleware can be either applied to all the URLs or some particular URLs.

Let's apply the middleware to all the URLs.

Step 1: Open the kernel.php file. If we want to apply the middleware to all
the URLs, then add the path of the middleware in the array of middleware.
Step 2: Type the command php artisan serve in Git Bash Window.
Step 3: Open the CheckAge.php file, which you have created as a
middleware.
Step 4: Now, enter the URL 'http://localhost/laravelproject/public/'.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 76
Unit I
Apply a Middleware

Let's apply the middleware to some specific routes.

Step 1: Open the kernel.php file. If we want to apply the middleware to


some specific routes

Step 2: Open the CheckAge.php file, which you have created as a


middleware.

Step 3: Add the middleware code in the web.php file.


Route::Get('/',function()
{
return view('welcome');
})-> middleware('age');
Route::Get('user/profile',function()
{
return "user profile";
});

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 77
Unit I
Controllers in Laravel

Controllers are used to handle the request logic within the single class, and
the controllers are defined in the "app/http/Controllers" directory.

Laravel framework follows the MVC (Model View Controller)


architecture in which controllers act as moving the traffic back and forth
between model and views.

The default file of controller is available in the app/http/Controllers


directory.
In code, the namespace is used as it allows you to use the same
function names and classes in the different parts of the same
application. For example,

namespace App\Http\functions1;
namespace App\Http\functions2;

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 78
Unit I
Cont…

Suppose we have to run the function having the name, i.e., RunQuery(). They
are available in different directories functions1 and functions2, so we can say
that namespace avoids the collision between the same function names.
'use' is used to import the class to the current file.

how to create the controller through Git Bash Window.

Step 1: Open the Git Bash Window and type the command
"php artisan make:Controller PostsController" in Git Bash Window to
create the Controller.
Step 2: Now move to your project and see whether the PostsController file
has been created or not. The path of the file is:

C:\xampp\htdocs\laravelproject\app\Http\Controllers

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 79
Unit I
Cont…

The above screenshot shows that the PostsController file is created.

You can check the default code of PostsController.php.

The code contains the class that extends the Controller class, but this class
does not contain the functions such as create, update, or delete. Now we
will see how to create the controller which contains some default
functions.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 80
Unit I
Cont…

To create the Controller, we will first delete the PostsController.php from the
project, which we have created in the previous step.

php artisan make:controller -resource PostController


this command is used to create the controller.

C:\xampp\htdocs\laravelproject\app\Http\Controllers

The above screen shows that PostController file is created successfully


Check default code of the PostController.php file.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 81
Unit I
Cont…

The code contains the functions which are used to perform the various
operations on the resources such as:

create(): It is used to create a new resource.

store(): It is used to store the specified resource.

update(): It is used to update the specified resource in the storage

destroy(): It is used to remove the specified resources from the storage

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 82
Unit I
RESTful Resource Controllers

Laravel resource controllers provide the CRUD routes to the controller in a


single line of code. A resource controller is used to create a controller that
handles all the http requests stored by your application.
The resource() is a static function like get() method that gives access to
multiple routes that we can use in a controller.
Syntax of resource() method:
Route::resource('posts','PostController');

In the above syntax, 'posts' contains all the routes, and 'PostController' is
the name of the controller. In this case, we do not need to specify the
method name such as @index as we did in get() method because create(),
store(), destroy() methods are already available in the PostController class.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 83
Unit I
RESTful Resource Controllers

Step 1: Create the controller by using the command given below:

php artisan make:controller PostController

The above command will create the Controller at


the app/Http/Controllers/PostController.php directory.
The PostController class contains the methods for each resource
operations.
Step 2: Now, we need to register the resourceful route to the Controller,
and which can be done as follows:

Route::resource('posts','PostController');

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 84
Unit I
RESTful Resource Controllers
Open the Git Bash Window, and enter the command php artisan
route:list. This command produces the following output:

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 85
Unit I
RESTful Resource Controllers

The post parameter in the resource() method produces the names or


resources shown in the above output, and its corresponding methods.
In the above output, the posts.destroy is sending a parameter to the
Delete method, which is very special in Laravel.

Let's understand the concept of resources through an


example.

Accessing the show() method of PostController class

Suppose we want to call the show() method of PostController.php


file.
To do so, add the code in show() method. I added the following code
in show() method:

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 86
Unit I
RESTful Resource Controllers

public function show($id)


{
return "show method is called and ID is : ".
$id
}

As we know that URI of the posts.show is posts/{posts}, which


means that we need to enter the parameter as well to access the
show() method of the PostController class.

Suppose I entered the URL as


'localhost/laravelproject/public/posts/58', then the output would
be:

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 87
Unit I
RESTful Resource Controllers

Accessing the create() method of PostController class

Step 1: First, we need to add the code in create() method.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 88
Unit I
RESTful Resource Controllers

public function create()


{
return "This is the create method";
}

As we know that the URI of the posts.create is posts/create, so the


URL to access the create() method would be

'localhost/laravelproject/public/posts/create'.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 89
Unit I
RESTful Resource Controllers

Step 2: Enter the URL


'localhost/laravelproject/public/posts/create' to the browser, then
the output would be:

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 90
Unit I
RESTful Resource Controllers

Registering routes for multiple controllers

We can register the routes for multiple controllers by passing an array


to the resources() method. Suppose I want to register the routes for
two controllers, such as PostController and StudentController.
Following are the steps to achieve this:

Step 1: First, you need to create


the PostController and StudentController by using the following
commands:
Php artisan make:controller PostController;
// to create the PostController.

Php artisan make:controller StudentControl


ler; // to create the StudentController.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 91
Unit I
RESTful Resource Controllers

Step 2: Add the code given below in web.php file to register routes:

route::resources(
['posts'=>'PostController',
'student'=>'StudentController']
);

Step 3: Enter the command php artisan route:list on Git Bash


Window.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 92
Unit I
RESTful Resource Controllers

The above screen shows that routes of both the PostController and
StudentController are registered.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 93
Unit I
Dependency Injection & Controllers

Constructor Injection:

The Laravel service container is used to resolve all Laravel controllers.


As a result, you are able to type-hint any dependencies your controller
may need in its constructor. The declared dependencies will
automatically be resolved and injected into the controller instance:

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 94
Unit I
Constructor Injection in Laravel

Constructor injection in Laravel is a form of dependency injection where


dependencies are injected into a class through its constructor. This approach
allows for the inversion of control, where the responsibility of creating and
managing dependencies is shifted to an external entity, typically Laravel's
service container.
1. Define Dependencies in the Constructor: In your class, you specify
the dependencies it requires in its constructor. These dependencies are
typically other classes or interfaces that the class relies on to perform
its tasks
In this example, the UserService class depends on the UserRepository
class. The UserRepository instance is injected into UserService through
its constructor.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 95
Unit I
Cont…

use App\Repositories\UserRepository;

class UserService
{
protected $userRepository;

public function
__construct(UserRepository
$userRepository)
{
$this->userRepository =
$userRepository;
}

// Other methods using $this-


>userRepository...
}
Rajat Kumar Vue.js Framework & Inertia.js
2/15/2024 96
Unit I
Cont…

2. Dependency Resolution by Laravel's Service Container: When


an instance of the class is requested (either directly or as a
dependency of another class), Laravel's service container resolves the
dependencies specified in the constructor and automatically injects
them.
3. Binding Dependencies: Before constructor injection can work,
dependencies must be registered with Laravel's service container. Laravel
provides various ways to bind dependencies, such as using service
providers, the AppServiceProvider, or directly in the container.

For example, you might bind UserRepository in the AppServiceProvider:

This binds UserRepository to a concrete implementation, ensuring that


Laravel knows how to resolve it when injected as a dependency.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 97
Unit I
Cont…

use App\Repositories\UserRepository;

class AppServiceProvider extends


ServiceProvider
{
public function register()
{
$this->app-
>bind(UserRepository::class, function
($app) {
return new UserRepository();
});
}
}

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 98
Unit I
Benefits of Constructor Injection

Testability: Constructor injection makes classes more testable by allowing


dependencies to be easily replaced with mock objects during unit testing.
This facilitates isolated testing of classes without needing to interact with
their actual dependencies.

Decoupling: Constructor injection promotes loose coupling between classes,


as classes depend on abstractions (interfaces or abstract classes) rather than
concrete implementations. This makes code more maintainable and flexible.

Readability: Explicitly declaring dependencies in the constructor improves


the readability of code by clearly documenting the class's requirements and
dependencies.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 99
Unit I
Method Injection in Laravel

Method injection in Laravel is a technique used for injecting dependencies


into controller methods or class methods automatically by the Laravel
service container.
This feature allows you to type-hint dependencies in your controller
methods, and Laravel will automatically resolve those dependencies and
pass them to the method when it is called.

Suppose you have a UserController with a method show that requires an


instance of UserService:

In this example, the show method of the UserController class receives an


instance of UserService through method injection. Laravel's service
container will automatically resolve and inject the UserService instance
when the show method is called.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 100
Unit I
Cont…

namespace App\Http\Controllers;

use App\Services\UserService;

class UserController extends Controller


{
public function show(UserService
$userService, $userId)
{
$user = $userService-
>getUserById($userId);
return view('user.show', ['user' =>
$user]);
}
}

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 101
Unit I
Cont…

you'll need to ensure that UserService is registered in Laravel's service


container, typically in the AppServiceProvider or a service provider dedicated
to your services.
bind UserService in the AppServiceProvider:

namespace App\Providers; public function register()


{
use Illuminate\Support\ServiceProvider; $this->app->bind(UserService::class,
use App\Services\UserService; function ($app) {
return new UserService(/*
class AppServiceProvider extends dependencies may be passed here */);
ServiceProvider });
{ }
}

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 102
Unit I
Rajat Kumar Vue.js Framework & Inertia.js
2/15/2024 103
Unit I
Rajat Kumar Vue.js Framework & Inertia.js
2/15/2024 104
Unit I
Rajat Kumar Vue.js Framework & Inertia.js
2/15/2024 105
Unit I
Rajat Kumar Vue.js Framework & Inertia.js
2/15/2024 106
Unit I
Laravel Sail

• Laravel Sail is a light-weight command-line interface for interacting with Laravel's


default Docker development environment. Sail provides a great starting point for
building a Laravel application using PHP, MySQL, and Redis without requiring prior
Docker experience.

• At its heart, Sail is the docker-compose.yml file and the sail script that is stored at
the root of your project. The sail script provides a CLI with convenient methods for
interacting with the Docker containers defined by the docker-compose.yml file.

• Laravel Sail is supported on macOS, Linux, and Windows (via WSL2).

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 107
Unit I
Cont…

Laravel Sail is automatically installed with all new Laravel applications


so you may start using it immediately. To learn how to create a new
Laravel application, please consult Laravel's installation
documentation for your operating system.

During installation, you will be asked to choose which Sail supported


services your application will be interacting with.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 108
Unit I
Installing Sail Into Existing Applications

If you are interested in using Sail with an existing Laravel application,


you may simply install Sail using the Composer package manager.
Of course, these steps assume that your existing local development
environment allows you to install Composer dependencies:

composer require laravel/sail --dev


After Sail has been installed, you may run the sail:install Artisan command.
This command will publish Sail's docker-compose.
yml file to the root of your application:

php artisan sail:install

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 109
Unit I
Laravel Jetstream

Laravel Jetstream is a beautifully designed application starter kit for Laravel


and provides the perfect starting point for your next Laravel application.
Jetstream provides the implementation for your application's login,
registration, email verification, two-factor authentication, session
management, API via Laravel Sanctum, and optional team management
features.
Jetstream is designed using Tailwind CSS and offers your choice
of Livewire or Inertia scaffolding

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 110
Unit I
Laravel Jetstream

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 111
Unit I
Laravel Jetstream

Available Stacks

Laravel Jetstream offers your choice of two frontend


stacks: Livewire and Inertia.js. Each stack provides a productive,
powerful starting point for building your application; however, the
stack you choose will depend on your preferred templating language.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 112
Unit I
Laravel Jetstream

Livewire + Blade

Laravel Livewire is a library that makes it simple to build modern,


reactive, dynamic interfaces using Laravel Blade as your templating
language.

This is a great stack to choose if you want to build an application


that is dynamic and reactive, and is a great alternative to a full
JavaScript framework like Vue.js.

When using Livewire, you may pick and choose which portions of
your application will be a Livewire component, while the remainder
of your application can be rendered as the traditional Blade
templates you are used to.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 113
Unit I
Laravel Jetstream

Inertia + Vue

The Inertia stack provided by Jetstream uses Vue.js as its templating


language. Building an Inertia application is a lot like building a typical Vue
application; however, you will use Laravel's router instead of Vue router.
Inertia is a small library that allows you to render single-file Vue
components from your Laravel backend by providing the name of the
component and the data that should be hydrated into that component's
"props".
In other words, this stack gives you the full power of Vue.js without the
complexity of client-side routing. You get to use the standard Laravel
routing and view data hydration approaches that you are used to.
The Inertia stack is a great choice if you are comfortable with and enjoy
using Vue.js as your templating language.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 114
Unit I
Daily Quiz

5. Where do we need to set database connection in Laravel?


• config.php
• setting.php
• In seed files
• .ENV file

6. hat is the minimum PHP version required to install Laravel 5.3?


• 7.1
• 5.6.4
• 5.3.2
• 5.4.3

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 115
Unit I
Faculty Video Links, Youtube & NPTEL Video Links and Online
Courses Details

• https://www.youtube.com/watch?v=ImtZ5yENzgE&ab_channel=freeCode
Camp.org
• https://www.youtube.com/watch?v=0yVDMcGp97g&list=PLjVLYmrlmjGfh
2rwJjrmKNHzGxCZwBsqj&ab_channel=WsCubeTech
• https://laravel.com/docs/4.2/introduction#:~:text=Laravel%20attempts%2
0to%20take%20the,developer%20without%20sacrificing%20application%
20functionality.
• https://www.tutorialspoint.com/laravel/laravel_overview.htm
• https://www.javatpoint.com/laravel

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 116
Unit I
Weekly Assignment

• What are the default route files in Laravel?


• What is the Laravel Framework?
• What are available databases supported by Laravel?
• What is an artisan?
• How to define environment variables in Laravel?
• How to put Laravel applications in maintenance mode?
• What are the advantages of using the Laravel framework to build complex
web applications?
• What is MVC architecture?
• How to create a route? Briefly describe with an example.

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 117
Unit I
MCQ s

1. What is the use of .env file in Laravel?


• Setting Up local Environment variable
• Optimization
• Hosting
• None of these

2. Command to start Laravel Application?


• php artisan new
• php artisan
• php artisan start
• php artisan serve

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 Unit I 118
MCQ s

3. Command to install laravel project?


• composer create-project laravel/laravel myproject
• composer new-project laravel/laravel myproject
• composer create-project new laravel/laravel myproject
• None of these

4. CLI Command to migrate in Laravel project?


• php artisan create migration
• php artisan migrate
• php artisan serve
• None of the above

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 Unit I 119
MCQ s

5. Command to make migration in laravel?


• php artisan migration table
• php artisan make:migration create_tags_table
• php artisan make-migration digit
• None of these

6. Command to check the status of migration in laravel application?


• php artisan migration status
• php artisan status
• php artisan migrate:status
• None of these

Rajat Kumar Vue.js Framework & Inertia.js


2/15/2024 Unit I 120
Glossary Questions

1. ………………create a controller in laravel by cmd?


• php artisan make: generate controller contoller_name
• php artisan make:controller generate
• php artisan make:controller --plain
• php artisan make:request controller_name create

2. View files in Laravel end in


• .blade.php
• .php
• .vue
• .blade

3. ………………method returns the average value of a given key ?


• average()
• avg()
• median()
• avg_val()

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 121


Glossary Questions

4. Which of the following is true about Laravel?


• Laravel is an open-source PHP framework
• Laravel is robust
• Laravel is easy to understand
• All of the above
5. Laravel uses ___________ to connect to an existing session and
general-purpose cache
• Queues
• Cron
• Redis
• Command Bus
6. The _______________ will run on every HTTP request of the
application
• Global Middleware
• Route Middleware
• Both A and B
• None of the above

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 122


Expected Questions for University Exam

• What are the main features of Laravel?


• Explain routing and their types in details.
• How will you explain middleware in Laravel?
• What do you know about PHP artisan? Mention some artisan command.
• What are the differences between Laravel and Codeigniter?
• What are the major differences between Laravel 4 and Laravel 5.x?
• How do you make and use Middleware in Laravel?

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 123


Recap of unit

Students learnt:
• Basic Laravel
• Laravel Features
• Installation of Laravel
• Routing and their types
• Configuration of Laravel
• Laravel jetStream

2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 124


2/15/2024 Rajat Kumar Vue.js Framework & Inertia.js Unit I 125

You might also like