SlideShare une entreprise Scribd logo
1  sur  35
Télécharger pour lire hors ligne
whoami 
• Ahmad Shah Hafizan Hamidin 
• 27 years old 
• Been developing for > 7 years 
• Laravel & Orchestra fanboy 
• https://www.github.com/ahmadshah 
• @penjajah 
• kuasamalaya
So What is Laravel?
+ +
Why so many Laravel? 
laravel/laravel! 
The framework structure and boilerplate codes 
! 
laravel/framework! 
The core of laravel framework or the kernel 
! 
Illuminate 
The namespace for every laravel framework 
components!
What do we need? 
• A webserver (Apache2/NGINX) 
• PHP 5.4 or above 
• Database engines (MySQL/PostgreSQL/MSSQL) 
• PHP mcrypt extension 
• Composer
Composer! 
• Remember PEAR? 
• Awesome PHP package management 
• Making developer lives easier 
• Manage application dependencies 
• http://getcomposer.org/ 
• http://packagist.com/
How to get Laravel?! 
via Laravel installer! 
> composer global require “laravel/installer=~1.1” 
> laravel new my-application 
! 
via Composer! 
> composer create-project laravel/laravel my-application
Laravel Setup 
• Make app/storage directory writable 
• Update public/.htaccess if you are using alias 
• Update app/config/database.php to connect 
to your database
M V C 
Eloquent, Blade and Controller
Laravel Routes 
• Handles the HTTP requests 
• GET, POST, PUT, PATCH, DELETE 
• All application routes are defined inside 
app/routes.php 
• Can accept Closures or controller 
namespace
Laravel Routes 
Route with Closure! 
Route::get(‘foobar’, function () { 
return ‘Welcome to FooBar!’; 
}); 
! 
Route with Controller! 
Route::get(‘foobar’, ‘FoobarController@index’);
Laravel Controllers 
• Handles the HTTP requests 
• GET, POST, PUT, PATCH, DELETE 
• Controllers are kept under app/controllers 
• Laravel naming convention: FoobarController 
• Extends IlluminateRoutingController class
Laravel Resourceful 
Controllers 
• Handles the HTTP requests 
• GET, POST, PUT, PATCH, DELETE 
• Predefine controller methods to handle 
the HTTP verbs 
• index, show, create, store, edit, 
update, and destroy
Laravel Resourceful! 
Controllers 
Route with Resource Controller! 
Route::resource(‘foobar’, ‘FoobarController’);
Laravel Views 
• The presentation layer of an application 
• Can accept either vanilla PHP or Blade 
files 
• View files are located under app/views 
directory 
• Can accept array arguments
Laravel Views 
Route with view! 
Route::get(‘foobar’, function () { 
return View::make(‘foobar’); 
});
Laravel Blade
Laravel Blade 
• Laravel default templating engine 
• Files need to use .blade.php extension 
• Driven by inheritance and sections 
• Extensible for adding new custom control 
structures
Laravel Blade 
Master layout! 
<!doctype html> 
… 
<body> 
@yield(‘content’) 
</body> 
</html> 
! 
Child layout! 
@extends(‘layout.master’) 
@section(‘content’) 
… 
@stop
Laravel Eloquent 
• Laravel ORM component 
• Simple ActiveRecord implementation 
• Each tables can be represented with a 
“Model” file 
• Model files are located under app/models 
directory 
• Extends IlluminateDatabaseEloquentModel 
class
Laravel Fluent 
• Laravel SQL query builder component 
• Write SQL query in a more elegant and readable 
way
Laravel Filters 
• Control the behaviour of a route 
• Process request before or after 
• Filters are located inside app/filters.php 
• Can be attached directly to route or controller 
• Can be in either Closure or filter class
Laravel Auth 
• Laravel user authentication component 
• Provide a basic functionalities to authenticate users 
• Does not come with ACL / RBAC 
• Utilizes app/models/User.php 
• Laravel does not come with a user table by default
Tinkering with the artisan
Laravel Artisan 
• Laravel CLI 
• Uses the Symfony Console component 
• Manage table migrations, seed tables, 
create resourceful controllers and many more 
• Developer best friend!
Service Providers & Facades
SOLID Principles 
Single Responsibility Principle! 
a class should have only one responsibility 
! 
Open/Closed Principle! 
open for extension and closed for modification 
! 
Liskov Substitution Principle 
Subtypes must be substitutable for their base types!
SOLID Principles 
Interface Segregation Principle! 
many client-specific interfaces are better 
! 
Dependency Inversion Principle! 
depends on abstraction 
! 
!
Laravel IOC 
• Inversion Of Control 
• Manages class dependencies 
• Based on dependency injection method 
• Dependencies are injected at run-time 
• Allowing dependencies to be easily swapped
Laravel Service Providers 
• Act like a component bootstrap 
• Group related IoC registrations in one place 
• Can also run other functionalities like 
artisan commands
Laravel Facades 
• Provide static interfaces to classes 
• Classes are resolved via IoC containers 
• Laravel is full with facades such as View, 
Cache, Config and others
Laravel Workbench 
• A tool to help develop laravel based components 
• Scaffold the necessary boilerplates 
• We do not commit/ship workbench directory

Contenu connexe

Tendances

Tendances (20)

laravel.pptx
laravel.pptxlaravel.pptx
laravel.pptx
 
Laravel
LaravelLaravel
Laravel
 
Why Laravel?
Why Laravel?Why Laravel?
Why Laravel?
 
Web Development with Laravel 5
Web Development with Laravel 5Web Development with Laravel 5
Web Development with Laravel 5
 
Spring boot
Spring bootSpring boot
Spring boot
 
Lecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptxLecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptx
 
Laravel - The PHP Framework for Web Artisans
Laravel - The PHP Framework for Web ArtisansLaravel - The PHP Framework for Web Artisans
Laravel - The PHP Framework for Web Artisans
 
Laravel Eloquent ORM
Laravel Eloquent ORMLaravel Eloquent ORM
Laravel Eloquent ORM
 
Tomcat
TomcatTomcat
Tomcat
 
introduction to Vue.js 3
introduction to Vue.js 3 introduction to Vue.js 3
introduction to Vue.js 3
 
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
 
Angular
AngularAngular
Angular
 
Laravel Routing and Query Building
Laravel   Routing and Query BuildingLaravel   Routing and Query Building
Laravel Routing and Query Building
 
Python/Flask Presentation
Python/Flask PresentationPython/Flask Presentation
Python/Flask Presentation
 
Spring Boot and REST API
Spring Boot and REST APISpring Boot and REST API
Spring Boot and REST API
 
Introduction to RxJS
Introduction to RxJSIntroduction to RxJS
Introduction to RxJS
 
Laravel tutorial
Laravel tutorialLaravel tutorial
Laravel tutorial
 
Express js
Express jsExpress js
Express js
 
Pentesting RESTful webservices
Pentesting RESTful webservicesPentesting RESTful webservices
Pentesting RESTful webservices
 
API for Beginners
API for BeginnersAPI for Beginners
API for Beginners
 

Similaire à Laravel Introduction

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 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
 
PHP Laravel Framework'üne Dalış
PHP Laravel Framework'üne DalışPHP Laravel Framework'üne Dalış
PHP Laravel Framework'üne Dalışemirkarsiyakali
 
Introduction to Laravel
Introduction to LaravelIntroduction to Laravel
Introduction to LaravelEli Wheaton
 
Chef, Vagrant and Friends
Chef, Vagrant and FriendsChef, Vagrant and Friends
Chef, Vagrant and FriendsBen McRae
 
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
 
Lecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdfLecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdfShaimaaMohamedGalal
 
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 TutorialAdventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 TutorialJoe Ferguson
 
PLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring SurfPLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring SurfAlfresco Software
 
How to Install Laravel 5.7
How to Install Laravel 5.7How to Install Laravel 5.7
How to Install Laravel 5.7Shubham Sunny
 
Apache Tutorial
Apache TutorialApache Tutorial
Apache TutorialGuru99
 
Frequently Asked Questions About Laravel
Frequently Asked Questions About LaravelFrequently Asked Questions About Laravel
Frequently Asked Questions About LaravelAResourcePool
 
The First Class Integration of Solr with Hadoop
The First Class Integration of Solr with HadoopThe First Class Integration of Solr with Hadoop
The First Class Integration of Solr with Hadooplucenerevolution
 
PLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring SurfPLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring SurfAlfresco Software
 
PLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring SurfPLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring SurfAlfresco Software
 

Similaire à Laravel Introduction (20)

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 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
 
PHP Laravel Framework'üne Dalış
PHP Laravel Framework'üne DalışPHP Laravel Framework'üne Dalış
PHP Laravel Framework'üne Dalış
 
Introduction to Laravel
Introduction to LaravelIntroduction to Laravel
Introduction to Laravel
 
Laravel
LaravelLaravel
Laravel
 
Chef, Vagrant and Friends
Chef, Vagrant and FriendsChef, Vagrant and Friends
Chef, Vagrant and Friends
 
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)
 
Lecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdfLecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdf
 
Laravel Meetup
Laravel MeetupLaravel Meetup
Laravel Meetup
 
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 TutorialAdventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
 
PLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring SurfPLAT-8 Spring Web Scripts and Spring Surf
PLAT-8 Spring Web Scripts and Spring Surf
 
How to Install Laravel 5.7
How to Install Laravel 5.7How to Install Laravel 5.7
How to Install Laravel 5.7
 
Apache Tutorial
Apache TutorialApache Tutorial
Apache Tutorial
 
Laravel 4 presentation
Laravel 4 presentationLaravel 4 presentation
Laravel 4 presentation
 
Getting started with laravel
Getting started with laravelGetting started with laravel
Getting started with laravel
 
Frequently Asked Questions About Laravel
Frequently Asked Questions About LaravelFrequently Asked Questions About Laravel
Frequently Asked Questions About Laravel
 
The First Class Integration of Solr with Hadoop
The First Class Integration of Solr with HadoopThe First Class Integration of Solr with Hadoop
The First Class Integration of Solr with Hadoop
 
PLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring SurfPLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring Surf
 
PLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring SurfPLAT-7 Spring Web Scripts and Spring Surf
PLAT-7 Spring Web Scripts and Spring Surf
 
ReactPHP + Symfony
ReactPHP + SymfonyReactPHP + Symfony
ReactPHP + Symfony
 

Dernier

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

Dernier (20)

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

Laravel Introduction

  • 1.
  • 2. whoami • Ahmad Shah Hafizan Hamidin • 27 years old • Been developing for > 7 years • Laravel & Orchestra fanboy • https://www.github.com/ahmadshah • @penjajah • kuasamalaya
  • 3. So What is Laravel?
  • 4. + +
  • 5. Why so many Laravel? laravel/laravel! The framework structure and boilerplate codes ! laravel/framework! The core of laravel framework or the kernel ! Illuminate The namespace for every laravel framework components!
  • 6. What do we need? • A webserver (Apache2/NGINX) • PHP 5.4 or above • Database engines (MySQL/PostgreSQL/MSSQL) • PHP mcrypt extension • Composer
  • 7. Composer! • Remember PEAR? • Awesome PHP package management • Making developer lives easier • Manage application dependencies • http://getcomposer.org/ • http://packagist.com/
  • 8. How to get Laravel?! via Laravel installer! > composer global require “laravel/installer=~1.1” > laravel new my-application ! via Composer! > composer create-project laravel/laravel my-application
  • 9.
  • 10. Laravel Setup • Make app/storage directory writable • Update public/.htaccess if you are using alias • Update app/config/database.php to connect to your database
  • 11. M V C Eloquent, Blade and Controller
  • 12. Laravel Routes • Handles the HTTP requests • GET, POST, PUT, PATCH, DELETE • All application routes are defined inside app/routes.php • Can accept Closures or controller namespace
  • 13. Laravel Routes Route with Closure! Route::get(‘foobar’, function () { return ‘Welcome to FooBar!’; }); ! Route with Controller! Route::get(‘foobar’, ‘FoobarController@index’);
  • 14. Laravel Controllers • Handles the HTTP requests • GET, POST, PUT, PATCH, DELETE • Controllers are kept under app/controllers • Laravel naming convention: FoobarController • Extends IlluminateRoutingController class
  • 15. Laravel Resourceful Controllers • Handles the HTTP requests • GET, POST, PUT, PATCH, DELETE • Predefine controller methods to handle the HTTP verbs • index, show, create, store, edit, update, and destroy
  • 16. Laravel Resourceful! Controllers Route with Resource Controller! Route::resource(‘foobar’, ‘FoobarController’);
  • 17. Laravel Views • The presentation layer of an application • Can accept either vanilla PHP or Blade files • View files are located under app/views directory • Can accept array arguments
  • 18. Laravel Views Route with view! Route::get(‘foobar’, function () { return View::make(‘foobar’); });
  • 20. Laravel Blade • Laravel default templating engine • Files need to use .blade.php extension • Driven by inheritance and sections • Extensible for adding new custom control structures
  • 21. Laravel Blade Master layout! <!doctype html> … <body> @yield(‘content’) </body> </html> ! Child layout! @extends(‘layout.master’) @section(‘content’) … @stop
  • 22. Laravel Eloquent • Laravel ORM component • Simple ActiveRecord implementation • Each tables can be represented with a “Model” file • Model files are located under app/models directory • Extends IlluminateDatabaseEloquentModel class
  • 23. Laravel Fluent • Laravel SQL query builder component • Write SQL query in a more elegant and readable way
  • 24. Laravel Filters • Control the behaviour of a route • Process request before or after • Filters are located inside app/filters.php • Can be attached directly to route or controller • Can be in either Closure or filter class
  • 25. Laravel Auth • Laravel user authentication component • Provide a basic functionalities to authenticate users • Does not come with ACL / RBAC • Utilizes app/models/User.php • Laravel does not come with a user table by default
  • 27.
  • 28. Laravel Artisan • Laravel CLI • Uses the Symfony Console component • Manage table migrations, seed tables, create resourceful controllers and many more • Developer best friend!
  • 30. SOLID Principles Single Responsibility Principle! a class should have only one responsibility ! Open/Closed Principle! open for extension and closed for modification ! Liskov Substitution Principle Subtypes must be substitutable for their base types!
  • 31. SOLID Principles Interface Segregation Principle! many client-specific interfaces are better ! Dependency Inversion Principle! depends on abstraction ! !
  • 32. Laravel IOC • Inversion Of Control • Manages class dependencies • Based on dependency injection method • Dependencies are injected at run-time • Allowing dependencies to be easily swapped
  • 33. Laravel Service Providers • Act like a component bootstrap • Group related IoC registrations in one place • Can also run other functionalities like artisan commands
  • 34. Laravel Facades • Provide static interfaces to classes • Classes are resolved via IoC containers • Laravel is full with facades such as View, Cache, Config and others
  • 35. Laravel Workbench • A tool to help develop laravel based components • Scaffold the necessary boilerplates • We do not commit/ship workbench directory