SlideShare a Scribd company logo
1 of 26
PHP Framework: Laravel
Course Code: CSC 4182
Dept. of Computer Science
Faculty of Science and Technology
Lecture No: 3 Week No: 02 Semester: Summer 2021-2022
Lecturer: RASHIDUL HASAN NABIL; rashidul@aiub.edu
Course Title: Advanced Programming In Web Technologies
Lecture Outline
1. Introduction to Laravel
2. Starting the framework
3. Laravel directory structure
4. Routing basics
5. Routing Options
6. View Engine (Blade)
7. Creating Views
Introduction to Laravel
Why Laravel?
• Laravel is a web application framework with expressive, elegant syntax.
• Laravel makes easy the tasks of authentication, session, caching in web
projects.
• Powerful web applications can be made with Laravel.
• Laravel framework makes implementation of authentication techniques
very simple. Laravel provides a very simple way to organize authorization
logic and control access to various resources.
• Laravel is the best PHP framework as it has Object Oriented libraries and
other pre-installed ones, which are not found in any other PHP frameworks.
• Laravel framework offers a build in a tool named Artisan. This tool allows a
developer to perform the majority of those repetitive and tedious
programming tasks which most of the developers avoid performing
manually.
Why Laravel?
• Another reason which makes Laravel the best PHP framework is it supports
MVC Architecture like Symfony, ensuring clarity between logic and
presentation.
• Laravel takes care of the security within its framework. It uses the hashed
password, which means that the password would never save as the plain
text in the database. Laravel framework uses prepared SQL statements
which make injection attacks unimaginable.
• With Laravel framework database migrations, it is extremely easy. As long
as you keep all of the database work in migrations and seeds, you can easily
migrate the changes into any other development machine you have.
• The Blade templating engine of the Laravel framework is very intuitive and
helps to work with the typical PHP/HTML spaghetti so perfect, that’s it one
of the best features of the Laravel framework.
Installation Process
• We will be using windows operating system.
• Laravel utilizes Composer to manage its dependencies.
• At first install XAMPP which supports apace and mysql(MariaDB)
• Download composer from https://getcomposer.org/download/
• Git bash can be used.
• Install composer.
• Choose your text editor.(Notepad++,VSCode,Sublime etc.)
Installation Process
What is composer?
• Compose is a tool which is used for dependency management for the
framework
• It allows you to declare the libraries your project depends on and it will
manage (install/update) them for you.
• It manages libraries on a per-project basis, installing them in a directory
(e.g. vendor) inside your project.
• You can update all your dependencies in one command with composer
• Composer requires PHP 5.3.2+ to run.
• Composer is multi-platform and we strive to make it run equally well on
Windows, Linux and macOS.
• With composer its very easy to create and manage projects and update
dependencies.
Starting the Framework
Creating the project
• PHP codes are to be placed in htdocs folder.
• If you have git bash installed you can use it for running commands.
• You can also use cmd application of windows.
• Open cmd in htdocs folder.
Click here
Type cmd
Hit enter
Creating the project
• With composer we will be creating the project.
• Write the below command to create a project.
composer create-project laravel/laravel your_project_name
• Composer will download the required dependencies and create the project.
• You will have your project created with required dependencies.
Running the project
• The Laravel project can be run by 2 ways
• With apache (Like other php apps we studied)
• With built in development server
• With apache
• Open Xampp
• Start apache
• Open browser and type http://localhost/demo_project_laravel/
• You will get the application directory
• Click on public folder the default project interface will appear
• You can also directly browse http://localhost/demo_project_laravel/public/
• If you have running apache in any customized port like 8082 then
don’t forget to mention the port like
http://localhost:8082/demo_project_laravel/public/
Running the project with apache
Running the project with built in development server
• In Laravel, we can run Laravel Development server by typing php
artisan serve command on terminal or command line.
• Open cmd in project directory and type
php artisan serve
• By default it will run in 8000 port. If 8000 is used then use another
port.
php artisan serve --port=8082
• The server will run now type
localhost:8000 [for default]
localhost:8082 [for customized port]
• This is the URL of your project.
• To stop the server type ctrl+c in the cmd.
• It will directly take you to public folder.
Application Directory Structure
Directory Structure
• app - The app directory contains the core code of your application. We'll
explore this directory in more detail soon; however, almost all of the
classes in your application will be in this directory.
• bootstrap - The bootstrap directory contains the app.php file which
bootstraps the framework. This directory also houses a cache directory
which contains framework generated files for performance
optimization such as the route and services cache files.
• config - The config directory, as the name implies, contains all of your
application's configuration files. It's a great idea to read through all of
these files and familiarize yourself with all of the options available to
you.
• database - The database directory contains your database migrations,
model factories, and seeds. If you wish, you may also use this directory
to hold an SQLite database.
• public - The public directory contains the index.php file, which is the
entry point for all requests entering your application and configures
autoloading. This directory also houses your assets such as images,
JavaScript, and CSS.
• resources - The resources directory contains your views as well as your
raw, un-compiled assets such as LESS, SASS, or JavaScript. This
directory also houses all of your language files.
Directory Structure
• routes - The routes directory contains all of the route definitions for
your application. By default, several route files are included with
Laravel: web.php, api.php, console.php and channels.php.
• storage - The storage directory contains your compiled Blade
templates, file based sessions, file caches, and other files generated by
the framework.
• app - The app directory may be used to store any files generated
by your application.
• framework - The framework directory is used to store framework
generated files and caches.
• logs - the logs directory contains your application's log files.
Generally storage/app/public is used to store files. In that case you
should
create a link with public/storage by php artisan storage:link command.
• test - The tests directory contains your automated tests.
• vendor - The vendor directory contains your Composer dependencies.
app Directory Structure
• Console - The Console directory contains all of the custom Artisan
commands for your application. These commands may be generated
using the make:command command. This directory also houses your console
kernel, which is where your custom Artisan commands are registered and
your scheduled tasks are defined.
• Exceptions - The Exceptions directory contains your application's
exception handler and is also a good place to place any exceptions thrown
by your application. If you would like to customize how your exceptions
are logged or rendered, you should modify the Handler class in this
directory.
• Http - The Http directory contains your controllers, middleware, and form
requests. Almost all of the logic to handle requests entering your
application will be placed in this directory.
• Providers - The Providers directory contains all of the service providers
for your application. Service providers bootstrap your application by
binding services in the service container, registering events, or
performing any other tasks to prepare your application for incoming
requests.
• Mail - This directory does not exist by default, but will be created for you
if you execute the make:mail Artisan command. The Mail directory
contains all of your classes that represent emails sent by your application.
Laravel Routing
• Routing is one of the essential concepts in Laravel.
• Routing in Laravel allows you to route all your application requests to its
appropriate controller.
• The most basic Laravel routes accept a URI and a Closure, providing a very
simple and expressive method of defining routes.
Route::method(uri,closure);
Route::get('/hello', function () {
return 'Hello World';
});
• All Laravel routes are defined in your route files, which are located in the
routes directory.
• These files are automatically loaded by the framework. The routes/web.php file
defines routes that are for your web interface.
URI
Closure
Routing
• These routes are assigned the web middleware group, which provides
features like session state and CSRF protection.
• For most applications, you will begin by defining routes in your routes/web.php
file.
• The routes defined in routes/web.php may be accessed by entering the defined
route's URL in your browser.
• http://localhost:8000/hello
• We can also write necessary functions in other files and bind them with route.
• Available routing 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);
• If you are defining a route that redirects to another URI, you may use the
Route::redirect method.
Route::redirect('/here', '/there');
Creating First Route
• Open routes/web.php in any text editor. Here VsCode will be used.
• Write a route
Route::get('/hello', function () {
return 'Hello World';
});
• Type the route in browser
• http://localhost:8000/hello
• Try this
Route::get('/hello/bold', function () {
return '<h1>Hello World</h1>';
});
• Output
• You can add as much routes you can and also add HTML with it.
Routing Options
In the second parameter of the route, we have the following options:
 A Closure
 An Array
 A String
Example:
Closure: Route::get('/home', function(){return "Hello"});
Array: Route::get('/home', ['uses'=>'HomeController@index']);
String: Route::get('/home', 'HomeController@index'});
View Engine (Blade)
• Till now we can create routes and give output in HTML we can add HTML tags
and design also but its not convenient to write HTML codes here.
• Views typically contain the HTML of your application and provide a convenient
way of separating your controller and domain logic from your presentation
logic.
<html>
<body>
<h1>Hello, Form View</h1>
</body>
</html>
• For views we will be using blade engine. Blade is the simple, yet powerful
templating engine provided with Laravel.
• Unlike other popular PHP templating engines, Blade does not restrict you from
using plain PHP code in your views.
• Blade views are compiled into plain PHP code and cached until they are
modified, meaning Blade adds essentially zero overhead to your application.
View Engine (Blade)
• Blade view files use the .blade.php file extension.
• Files with blade are stored in the resources/views directory.
• Using blade as Layout will be discussed later studies. Lets create our first view.
CreatingViews
• Go to resources/views
• Create a file with .blade.php
• Put some html codes
• After creating views we need to bind it with
Route
• Go to web.php and define a route or
Modify existing one
Route::get('/hello',function(){
return view("hello");
})->name('hello');
• view() function receives the blade file name.
Give only the file name without .blade.php
Books
 PHP Advanced and Object-Oriented Programming, 3rd Edition; Larry
Ullman; Peachpit, Press, 2013
 PHP Objects, Patterns and Practice, 5th Edition; Matt Zandstra; Apress,
2016
 Learning PHP, MySQL, JavaScript and CSS, 2nd Edition; Robin Nixon;
O’Reilly, 2009
 Eloquent JavaScript: A Modern Introduction to Programming; Marijn
Haverbeke; 2011
 Learning Node.js: A Hands On Guide to Building Web Applications in
JavaScript; Marc Wandschneider; Addison-Wesley, 2013
 Beginning Node.js; Basarat Ali Syed; Apress, 2014
References
1. https://laravel.com/
2. https://getcomposer.org/
3. http://www.laravelinterviewquestions.com/
Thank You!

More Related Content

What's hot

Object Oriented Programming with Laravel - Session 3
Object Oriented Programming with Laravel - Session 3Object Oriented Programming with Laravel - Session 3
Object Oriented Programming with Laravel - Session 3Shahrzad Peyman
 
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Dilouar Hossain
 
Laravel tutorial
Laravel tutorialLaravel tutorial
Laravel tutorialBroker IG
 
Projects In Laravel : Learn Laravel Building 10 Projects
Projects In Laravel : Learn Laravel Building 10 ProjectsProjects In Laravel : Learn Laravel Building 10 Projects
Projects In Laravel : Learn Laravel Building 10 ProjectsSam Dias
 
What-is-Laravel-23-August-2017.pptx
What-is-Laravel-23-August-2017.pptxWhat-is-Laravel-23-August-2017.pptx
What-is-Laravel-23-August-2017.pptxAbhijeetKumar456867
 
Laravel introduction
Laravel introductionLaravel introduction
Laravel introductionSimon Funk
 
Object Oriented Programming with Laravel - Session 1
Object Oriented Programming with Laravel - Session 1Object Oriented Programming with Laravel - Session 1
Object Oriented Programming with Laravel - Session 1Shahrzad Peyman
 
Object Oriented Programming with Laravel - Session 2
Object Oriented Programming with Laravel - Session 2Object Oriented Programming with Laravel - Session 2
Object Oriented Programming with Laravel - Session 2Shahrzad Peyman
 
Laravel Routing and Query Building
Laravel   Routing and Query BuildingLaravel   Routing and Query Building
Laravel Routing and Query BuildingMindfire Solutions
 
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...Edureka!
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask PresentationParag Mujumdar
 
Web application development with laravel php framework version 4
Web application development with laravel php framework version 4Web application development with laravel php framework version 4
Web application development with laravel php framework version 4Untung D Saptoto
 

What's hot (20)

Object Oriented Programming with Laravel - Session 3
Object Oriented Programming with Laravel - Session 3Object Oriented Programming with Laravel - Session 3
Object Oriented Programming with Laravel - Session 3
 
Laravel Tutorial PPT
Laravel Tutorial PPTLaravel Tutorial PPT
Laravel Tutorial PPT
 
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
 
Why Laravel?
Why Laravel?Why Laravel?
Why Laravel?
 
Laravel tutorial
Laravel tutorialLaravel tutorial
Laravel tutorial
 
Projects In Laravel : Learn Laravel Building 10 Projects
Projects In Laravel : Learn Laravel Building 10 ProjectsProjects In Laravel : Learn Laravel Building 10 Projects
Projects In Laravel : Learn Laravel Building 10 Projects
 
Laravel Eloquent ORM
Laravel Eloquent ORMLaravel Eloquent ORM
Laravel Eloquent ORM
 
What-is-Laravel-23-August-2017.pptx
What-is-Laravel-23-August-2017.pptxWhat-is-Laravel-23-August-2017.pptx
What-is-Laravel-23-August-2017.pptx
 
Laravel introduction
Laravel introductionLaravel introduction
Laravel introduction
 
Laravel Blade Template
Laravel Blade TemplateLaravel Blade Template
Laravel Blade Template
 
Object Oriented Programming with Laravel - Session 1
Object Oriented Programming with Laravel - Session 1Object Oriented Programming with Laravel - Session 1
Object Oriented Programming with Laravel - Session 1
 
Laravel ppt
Laravel pptLaravel ppt
Laravel ppt
 
Laravel
LaravelLaravel
Laravel
 
Laravel
LaravelLaravel
Laravel
 
Object Oriented Programming with Laravel - Session 2
Object Oriented Programming with Laravel - Session 2Object Oriented Programming with Laravel - Session 2
Object Oriented Programming with Laravel - Session 2
 
Laravel Routing and Query Building
Laravel   Routing and Query BuildingLaravel   Routing and Query Building
Laravel Routing and Query Building
 
Codeigniter framework
Codeigniter framework Codeigniter framework
Codeigniter framework
 
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
Java Interview Questions and Answers | Spring and Hibernate Interview Questio...
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
 
Web application development with laravel php framework version 4
Web application development with laravel php framework version 4Web application development with laravel php framework version 4
Web application development with laravel php framework version 4
 

Similar to Lecture 2_ Intro to laravel.pptx

Lecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdfLecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdfShaimaaMohamedGalal
 
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin Lorvent56
 
Laravel (8) php_framework_handbook__start_from_zer_18604872_(z-lib.org)
Laravel (8) php_framework_handbook__start_from_zer_18604872_(z-lib.org)Laravel (8) php_framework_handbook__start_from_zer_18604872_(z-lib.org)
Laravel (8) php_framework_handbook__start_from_zer_18604872_(z-lib.org)ssuser337865
 
Laravel - A Trending PHP Framework
Laravel - A Trending PHP FrameworkLaravel - A Trending PHP Framework
Laravel - A Trending PHP Frameworkijtsrd
 
Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)Viral Solani
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Railsanides
 
開放原始碼 Ch1.2 intro - oss - apahce foundry (ver 2.0)
開放原始碼 Ch1.2   intro - oss - apahce foundry (ver 2.0)開放原始碼 Ch1.2   intro - oss - apahce foundry (ver 2.0)
開放原始碼 Ch1.2 intro - oss - apahce foundry (ver 2.0)My own sweet home!
 
How to Install Laravel 5.7
How to Install Laravel 5.7How to Install Laravel 5.7
How to Install Laravel 5.7Shubham Sunny
 
Directory Structure Changes in Laravel 5.3
Directory Structure Changes in Laravel 5.3Directory Structure Changes in Laravel 5.3
Directory Structure Changes in Laravel 5.3DHRUV NATH
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuis Rodríguez Castromil
 
Rails
RailsRails
RailsSHC
 

Similar to Lecture 2_ Intro to laravel.pptx (20)

Lecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdfLecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdf
 
Laravel
LaravelLaravel
Laravel
 
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
 
Laravel (8) php_framework_handbook__start_from_zer_18604872_(z-lib.org)
Laravel (8) php_framework_handbook__start_from_zer_18604872_(z-lib.org)Laravel (8) php_framework_handbook__start_from_zer_18604872_(z-lib.org)
Laravel (8) php_framework_handbook__start_from_zer_18604872_(z-lib.org)
 
Getting started with laravel
Getting started with laravelGetting started with laravel
Getting started with laravel
 
Laravel - A Trending PHP Framework
Laravel - A Trending PHP FrameworkLaravel - A Trending PHP Framework
Laravel - A Trending PHP Framework
 
Laravel 4 presentation
Laravel 4 presentationLaravel 4 presentation
Laravel 4 presentation
 
Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
開放原始碼 Ch1.2 intro - oss - apahce foundry (ver 2.0)
開放原始碼 Ch1.2   intro - oss - apahce foundry (ver 2.0)開放原始碼 Ch1.2   intro - oss - apahce foundry (ver 2.0)
開放原始碼 Ch1.2 intro - oss - apahce foundry (ver 2.0)
 
How to Install Laravel 5.7
How to Install Laravel 5.7How to Install Laravel 5.7
How to Install Laravel 5.7
 
Laravel 5.3 - Web Development Php framework
Laravel 5.3 - Web Development Php frameworkLaravel 5.3 - Web Development Php framework
Laravel 5.3 - Web Development Php framework
 
Directory Structure Changes in Laravel 5.3
Directory Structure Changes in Laravel 5.3Directory Structure Changes in Laravel 5.3
Directory Structure Changes in Laravel 5.3
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
 
sveltekit-en.pdf
sveltekit-en.pdfsveltekit-en.pdf
sveltekit-en.pdf
 
Solr Recipes
Solr RecipesSolr Recipes
Solr Recipes
 
Rails
RailsRails
Rails
 
12 Introduction to Rails
12 Introduction to Rails12 Introduction to Rails
12 Introduction to Rails
 
Lamp
LampLamp
Lamp
 
Apache ppt
Apache pptApache ppt
Apache ppt
 

Recently uploaded

Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts servicevipmodelshub1
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsstephieert
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsThierry TROUIN ☁
 
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
Russian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
Russian Call Girls Thane Swara 8617697112 Independent Escort Service ThaneRussian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
Russian Call Girls Thane Swara 8617697112 Independent Escort Service ThaneCall girls in Ahmedabad High profile
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...SofiyaSharma5
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...aditipandeya
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts servicesonalikaur4
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)Damian Radcliffe
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on DeliveryCall Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Deliverybabeytanya
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girlsstephieert
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxellan12
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Sheetaleventcompany
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirtrahman018755
 

Recently uploaded (20)

Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls KolkataLow Rate Call Girls Kolkata Avani 🤌  8250192130 🚀 Vip Call Girls Kolkata
Low Rate Call Girls Kolkata Avani 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Alwarpet Phone 🍆 8250192130 👅 celebrity escorts service
 
Radiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girlsRadiant Call girls in Dubai O56338O268 Dubai Call girls
Radiant Call girls in Dubai O56338O268 Dubai Call girls
 
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
Dwarka Sector 26 Call Girls | Delhi | 9999965857 🫦 Vanshika Verma More Our Se...
 
AlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with FlowsAlbaniaDreamin24 - How to easily use an API with Flows
AlbaniaDreamin24 - How to easily use an API with Flows
 
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
10.pdfMature Call girls in Dubai +971563133746 Dubai Call girls
 
Russian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
Russian Call Girls Thane Swara 8617697112 Independent Escort Service ThaneRussian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
Russian Call Girls Thane Swara 8617697112 Independent Escort Service Thane
 
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Samaira 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Samaira 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
Low Rate Young Call Girls in Sector 63 Mamura Noida ✔️☆9289244007✔️☆ Female E...
 
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
VIP 7001035870 Find & Meet Hyderabad Call Girls Dilsukhnagar high-profile Cal...
 
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts serviceChennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
Chennai Call Girls Porur Phone 🍆 8250192130 👅 celebrity escorts service
 
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)
 
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Model Towh Delhi 💯Call Us 🔝8264348440🔝
 
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on DeliveryCall Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
Call Girls In Mumbai Central Mumbai ❤️ 9920874524 👈 Cash on Delivery
 
Russian Call girls in Dubai +971563133746 Dubai Call girls
Russian  Call girls in Dubai +971563133746 Dubai  Call girlsRussian  Call girls in Dubai +971563133746 Dubai  Call girls
Russian Call girls in Dubai +971563133746 Dubai Call girls
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya ShirtChallengers I Told Ya Shirt
Challengers I Told Ya ShirtChallengers I Told Ya Shirt
 

Lecture 2_ Intro to laravel.pptx

  • 1. PHP Framework: Laravel Course Code: CSC 4182 Dept. of Computer Science Faculty of Science and Technology Lecture No: 3 Week No: 02 Semester: Summer 2021-2022 Lecturer: RASHIDUL HASAN NABIL; rashidul@aiub.edu Course Title: Advanced Programming In Web Technologies
  • 2. Lecture Outline 1. Introduction to Laravel 2. Starting the framework 3. Laravel directory structure 4. Routing basics 5. Routing Options 6. View Engine (Blade) 7. Creating Views
  • 3. Introduction to Laravel Why Laravel? • Laravel is a web application framework with expressive, elegant syntax. • Laravel makes easy the tasks of authentication, session, caching in web projects. • Powerful web applications can be made with Laravel. • Laravel framework makes implementation of authentication techniques very simple. Laravel provides a very simple way to organize authorization logic and control access to various resources. • Laravel is the best PHP framework as it has Object Oriented libraries and other pre-installed ones, which are not found in any other PHP frameworks. • Laravel framework offers a build in a tool named Artisan. This tool allows a developer to perform the majority of those repetitive and tedious programming tasks which most of the developers avoid performing manually.
  • 4. Why Laravel? • Another reason which makes Laravel the best PHP framework is it supports MVC Architecture like Symfony, ensuring clarity between logic and presentation. • Laravel takes care of the security within its framework. It uses the hashed password, which means that the password would never save as the plain text in the database. Laravel framework uses prepared SQL statements which make injection attacks unimaginable. • With Laravel framework database migrations, it is extremely easy. As long as you keep all of the database work in migrations and seeds, you can easily migrate the changes into any other development machine you have. • The Blade templating engine of the Laravel framework is very intuitive and helps to work with the typical PHP/HTML spaghetti so perfect, that’s it one of the best features of the Laravel framework.
  • 5. Installation Process • We will be using windows operating system. • Laravel utilizes Composer to manage its dependencies. • At first install XAMPP which supports apace and mysql(MariaDB) • Download composer from https://getcomposer.org/download/ • Git bash can be used. • Install composer. • Choose your text editor.(Notepad++,VSCode,Sublime etc.)
  • 7. What is composer? • Compose is a tool which is used for dependency management for the framework • It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. • It manages libraries on a per-project basis, installing them in a directory (e.g. vendor) inside your project. • You can update all your dependencies in one command with composer • Composer requires PHP 5.3.2+ to run. • Composer is multi-platform and we strive to make it run equally well on Windows, Linux and macOS. • With composer its very easy to create and manage projects and update dependencies.
  • 8. Starting the Framework Creating the project • PHP codes are to be placed in htdocs folder. • If you have git bash installed you can use it for running commands. • You can also use cmd application of windows. • Open cmd in htdocs folder. Click here Type cmd Hit enter
  • 9. Creating the project • With composer we will be creating the project. • Write the below command to create a project. composer create-project laravel/laravel your_project_name • Composer will download the required dependencies and create the project. • You will have your project created with required dependencies.
  • 10. Running the project • The Laravel project can be run by 2 ways • With apache (Like other php apps we studied) • With built in development server • With apache • Open Xampp • Start apache • Open browser and type http://localhost/demo_project_laravel/ • You will get the application directory • Click on public folder the default project interface will appear • You can also directly browse http://localhost/demo_project_laravel/public/ • If you have running apache in any customized port like 8082 then don’t forget to mention the port like http://localhost:8082/demo_project_laravel/public/
  • 11. Running the project with apache
  • 12. Running the project with built in development server • In Laravel, we can run Laravel Development server by typing php artisan serve command on terminal or command line. • Open cmd in project directory and type php artisan serve • By default it will run in 8000 port. If 8000 is used then use another port. php artisan serve --port=8082 • The server will run now type localhost:8000 [for default] localhost:8082 [for customized port] • This is the URL of your project. • To stop the server type ctrl+c in the cmd. • It will directly take you to public folder.
  • 14. Directory Structure • app - The app directory contains the core code of your application. We'll explore this directory in more detail soon; however, almost all of the classes in your application will be in this directory. • bootstrap - The bootstrap directory contains the app.php file which bootstraps the framework. This directory also houses a cache directory which contains framework generated files for performance optimization such as the route and services cache files. • config - The config directory, as the name implies, contains all of your application's configuration files. It's a great idea to read through all of these files and familiarize yourself with all of the options available to you. • database - The database directory contains your database migrations, model factories, and seeds. If you wish, you may also use this directory to hold an SQLite database. • public - The public directory contains the index.php file, which is the entry point for all requests entering your application and configures autoloading. This directory also houses your assets such as images, JavaScript, and CSS. • resources - The resources directory contains your views as well as your raw, un-compiled assets such as LESS, SASS, or JavaScript. This directory also houses all of your language files.
  • 15. Directory Structure • routes - The routes directory contains all of the route definitions for your application. By default, several route files are included with Laravel: web.php, api.php, console.php and channels.php. • storage - The storage directory contains your compiled Blade templates, file based sessions, file caches, and other files generated by the framework. • app - The app directory may be used to store any files generated by your application. • framework - The framework directory is used to store framework generated files and caches. • logs - the logs directory contains your application's log files. Generally storage/app/public is used to store files. In that case you should create a link with public/storage by php artisan storage:link command. • test - The tests directory contains your automated tests. • vendor - The vendor directory contains your Composer dependencies.
  • 16. app Directory Structure • Console - The Console directory contains all of the custom Artisan commands for your application. These commands may be generated using the make:command command. This directory also houses your console kernel, which is where your custom Artisan commands are registered and your scheduled tasks are defined. • Exceptions - The Exceptions directory contains your application's exception handler and is also a good place to place any exceptions thrown by your application. If you would like to customize how your exceptions are logged or rendered, you should modify the Handler class in this directory. • Http - The Http directory contains your controllers, middleware, and form requests. Almost all of the logic to handle requests entering your application will be placed in this directory. • Providers - The Providers directory contains all of the service providers for your application. Service providers bootstrap your application by binding services in the service container, registering events, or performing any other tasks to prepare your application for incoming requests. • Mail - This directory does not exist by default, but will be created for you if you execute the make:mail Artisan command. The Mail directory contains all of your classes that represent emails sent by your application.
  • 17. Laravel Routing • Routing is one of the essential concepts in Laravel. • Routing in Laravel allows you to route all your application requests to its appropriate controller. • The most basic Laravel routes accept a URI and a Closure, providing a very simple and expressive method of defining routes. Route::method(uri,closure); Route::get('/hello', function () { return 'Hello World'; }); • All Laravel routes are defined in your route files, which are located in the routes directory. • These files are automatically loaded by the framework. The routes/web.php file defines routes that are for your web interface. URI Closure
  • 18. Routing • These routes are assigned the web middleware group, which provides features like session state and CSRF protection. • For most applications, you will begin by defining routes in your routes/web.php file. • The routes defined in routes/web.php may be accessed by entering the defined route's URL in your browser. • http://localhost:8000/hello • We can also write necessary functions in other files and bind them with route. • Available routing 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); • If you are defining a route that redirects to another URI, you may use the Route::redirect method. Route::redirect('/here', '/there');
  • 19. Creating First Route • Open routes/web.php in any text editor. Here VsCode will be used. • Write a route Route::get('/hello', function () { return 'Hello World'; }); • Type the route in browser • http://localhost:8000/hello • Try this Route::get('/hello/bold', function () { return '<h1>Hello World</h1>'; }); • Output • You can add as much routes you can and also add HTML with it.
  • 20. Routing Options In the second parameter of the route, we have the following options:  A Closure  An Array  A String Example: Closure: Route::get('/home', function(){return "Hello"}); Array: Route::get('/home', ['uses'=>'HomeController@index']); String: Route::get('/home', 'HomeController@index'});
  • 21. View Engine (Blade) • Till now we can create routes and give output in HTML we can add HTML tags and design also but its not convenient to write HTML codes here. • Views typically contain the HTML of your application and provide a convenient way of separating your controller and domain logic from your presentation logic. <html> <body> <h1>Hello, Form View</h1> </body> </html> • For views we will be using blade engine. Blade is the simple, yet powerful templating engine provided with Laravel. • Unlike other popular PHP templating engines, Blade does not restrict you from using plain PHP code in your views. • Blade views are compiled into plain PHP code and cached until they are modified, meaning Blade adds essentially zero overhead to your application.
  • 22. View Engine (Blade) • Blade view files use the .blade.php file extension. • Files with blade are stored in the resources/views directory. • Using blade as Layout will be discussed later studies. Lets create our first view.
  • 23. CreatingViews • Go to resources/views • Create a file with .blade.php • Put some html codes • After creating views we need to bind it with Route • Go to web.php and define a route or Modify existing one Route::get('/hello',function(){ return view("hello"); })->name('hello'); • view() function receives the blade file name. Give only the file name without .blade.php
  • 24. Books  PHP Advanced and Object-Oriented Programming, 3rd Edition; Larry Ullman; Peachpit, Press, 2013  PHP Objects, Patterns and Practice, 5th Edition; Matt Zandstra; Apress, 2016  Learning PHP, MySQL, JavaScript and CSS, 2nd Edition; Robin Nixon; O’Reilly, 2009  Eloquent JavaScript: A Modern Introduction to Programming; Marijn Haverbeke; 2011  Learning Node.js: A Hands On Guide to Building Web Applications in JavaScript; Marc Wandschneider; Addison-Wesley, 2013  Beginning Node.js; Basarat Ali Syed; Apress, 2014
  • 25. References 1. https://laravel.com/ 2. https://getcomposer.org/ 3. http://www.laravelinterviewquestions.com/