SlideShare uma empresa Scribd logo
1 de 22
By:
Mayank Panchal
We will learn today
• WHAT IS LARAVEL
• INSTALL LARAVEL 5 WITH COMPOSER
• FILES STRUCTURE
• WHAT IS ARTISAN AND HOW DOES IT SAVE US TIME
• ROUTING AND ROUTE TYPES
• WHAT IS MIDDLEWARE AND HOW TO USE IT
• WHAT IS BLADE ?
• DATABASE AND ELOQUENT ORM
• CRUD WITH VALIDATION AND DATABASE
CONNECTION (PRACTICAL TASK)
• BEST PRACTICES WHEN CODING IN LARAVEL
• Laravel is MVC PHP framework created by Taylor Otwell in
2011
• Free open-source license with many contributors worldwide
• One of the best frameworks together with Symfony,
CodeIgniter, Yii
• Has powerful features, saving us time
• Uses Symfony packages
What is
• Eloquent ORM (object-relational mapping) – implements Active-
Record
• Query builder – helps you to build secured SQL queries
• Restful controllers – provides a way for separating the different HTTP
requests (GET, POST, DELETE, etc.)
• Blade template engine – combines templates with a data model to
produce views
• Migrations – version control system for database, update your database
easier
• Database seeding – provides a way to populate database tables with test
data used for testing
• Pagination – easy to use advanced pagination functionalities
• Forms security – provides CSRF token middleware, protecting all the
forms
Features of
• Laravel uses Composer to manage its dependencies
• Composer is dependency management tool for PHP, like a library full of
books
• NOT like Yum or apt
• Per project tool (vendor folder), not per system
• Install by using the command:
composer create-project [PACKAGE] [DESTINATION PATH] [--FLAGS]
composer create-project laravel/laravel Laravel test
Let’s install
app/Http folder contains the Controllers, Middlewares and Kernel file
All the models should be located in app/Models folder
All the config files are located in app/config folder
The service providers that are bootstrapping functions in our
app are located in app/Providers folder
Folder Structure
Folder Structure
• Database folder contains the migrations and
seeds
• The public folder is the actual folder you are opening on
the web server.
All JS / CSS / Images / Uploads are located there.
• The resources folder contains all the translations, views
and assets (SASS, LESS, JS)
that are compiled into public folder
• The routes folder contains all the routes for the project
• All the logs / cache files are located in storage folder
• The vendor folder contains all the composer packages
(dependencies)
Artisan is command-line interface for Laravel
Commands that are saving time
Generating files with artisan is recommended
Run php artisan list in the console
Artisan!
• The best and easy routing system I’ve seen
• Routing per middleware / prefix or namespace
• Routing per request method (GET, POST,
DELETE, etc.)
• ALWAYS name your route !
• Be careful with the routing order !
Let’s see routing examples
Routing
• The middleware is mechanism for filtering the HTTP
requests
• Laravel includes several middleware's – Authentication,
CSRF Protection
• The auth middleware checks if the user visiting the page
is authenticated through session cookie
• The CSRF token protection middleware protects your
application from cross-site request forgery attacks by
adding token key for each generated form
Let’s create middleware
Middleware
• Blade is the powerful template engine provided by
Laravel
• All the code inside blade file is compiled to static html
file
• Supports plain PHP
• Saves time
• Better components mobility, extend and include partials
Let’s take a look at few examples
Blade
ELOQUENT & DATABASE
• THE ELOQUENT ORM (OBJECT-RELATIONAL MAPPING) PROVIDES SIMPLE ACTIVE RECORD
IMPLEMENTATION FOR WORKING WITH THE DATABASE
$article = new Article();
$article->title = ‘Article title’;
$article->description = ‘Description’;
$article->save();
INSERT INTO `article` (`title`, `description`) VALUES (‘Article title’, ‘Description’);
• EACH TABLE HAS ITS OWN “MODEL”. YOU CAN USE THE MODEL TO READ, INSERT, UPDATE OR
DELETE ROW FROM THE SPECIFIC TABLE
• LET’S CHECK ONE MODEL
Practical Task
Best practices in
• NEVER write queries or model logic inside
the controller! The controller job is to
communicate with the model and pass data to
the view.
Extend and include partials. For example share
the same form fields on 2 pages – add and edit
Views mobility
Always use the CSRF token protection that Laravel provides in forms you create, the hackers will not
be able to spam your forms and database
Forms security
Be careful with the database architecture, always use the proper length for specific column and never
forget the indexes for searchable columns
Database architecture
• Avoid the big query unless you really have
to do it. The big query is hard to debug
and understand.
• You can merge the small queries into one
to save the CPU time on server, but
sometimes the query becomes way too
big.
Big Query
Don’t forget to write comments for each
method or complicated logic.
The PHPDoc comments are helping the
IDE to autosuggest easier and the
developers to understand the piece of code
Don’t forget the PHPDoc
Thank you!
Questions

Mais conteúdo relacionado

Mais procurados (20)

Php Presentation
Php PresentationPhp Presentation
Php Presentation
 
Php introduction
Php introductionPhp introduction
Php introduction
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 
Bootstrap 5 ppt
Bootstrap 5 pptBootstrap 5 ppt
Bootstrap 5 ppt
 
JDBC: java DataBase connectivity
JDBC: java DataBase connectivityJDBC: java DataBase connectivity
JDBC: java DataBase connectivity
 
JQuery introduction
JQuery introductionJQuery introduction
JQuery introduction
 
Introduction to .NET Framework
Introduction to .NET FrameworkIntroduction to .NET Framework
Introduction to .NET Framework
 
An Introduction To REST API
An Introduction To REST APIAn Introduction To REST API
An Introduction To REST API
 
JavaScript - Chapter 6 - Basic Functions
 JavaScript - Chapter 6 - Basic Functions JavaScript - Chapter 6 - Basic Functions
JavaScript - Chapter 6 - Basic Functions
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
 
Vue.js
Vue.jsVue.js
Vue.js
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Introduction to xampp
Introduction to xamppIntroduction to xampp
Introduction to xampp
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 
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
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
 
Model View Controller (MVC)
Model View Controller (MVC)Model View Controller (MVC)
Model View Controller (MVC)
 
Xampp Ppt
Xampp PptXampp Ppt
Xampp Ppt
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
 
Php.ppt
Php.pptPhp.ppt
Php.ppt
 

Semelhante a Laravel ppt

Lecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptxLecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptxSaziaRahman
 
Web Development with Laravel 5
Web Development with Laravel 5Web Development with Laravel 5
Web Development with Laravel 5Soheil Khodayari
 
Lecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdfLecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdfShaimaaMohamedGalal
 
Solr Recipes Workshop
Solr Recipes WorkshopSolr Recipes Workshop
Solr Recipes WorkshopErik Hatcher
 
Salesforce Development Best Practices
Salesforce Development Best PracticesSalesforce Development Best Practices
Salesforce Development Best PracticesVivek Chawla
 
Frameworks Galore: A Pragmatic Review
Frameworks Galore: A Pragmatic ReviewFrameworks Galore: A Pragmatic Review
Frameworks Galore: A Pragmatic Reviewnetc2012
 
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...44CON
 
Lecture #5 Introduction to rails
Lecture #5 Introduction to railsLecture #5 Introduction to rails
Lecture #5 Introduction to railsEvgeniy Hinyuk
 
Introduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy HinyukIntroduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy HinyukPivorak MeetUp
 
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
 
Introduction to Laravel
Introduction to LaravelIntroduction to Laravel
Introduction to LaravelEli Wheaton
 
SilverStripe From a Developer's Perspective
SilverStripe From a Developer's PerspectiveSilverStripe From a Developer's Perspective
SilverStripe From a Developer's Perspectiveajshort
 
MySQL Day Paris 2016 - MySQL as a Document Store
MySQL Day Paris 2016 - MySQL as a Document StoreMySQL Day Paris 2016 - MySQL as a Document Store
MySQL Day Paris 2016 - MySQL as a Document StoreOlivier DASINI
 
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...J V
 
Salesforce Basic Development
Salesforce Basic DevelopmentSalesforce Basic Development
Salesforce Basic DevelopmentNaveen Dhanaraj
 

Semelhante a Laravel ppt (20)

Laravel
LaravelLaravel
Laravel
 
Lecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptxLecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptx
 
Solr Recipes
Solr RecipesSolr Recipes
Solr Recipes
 
Web Development with Laravel 5
Web Development with Laravel 5Web Development with Laravel 5
Web Development with Laravel 5
 
Laravel 4 presentation
Laravel 4 presentationLaravel 4 presentation
Laravel 4 presentation
 
Lecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdfLecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdf
 
Solr Recipes Workshop
Solr Recipes WorkshopSolr Recipes Workshop
Solr Recipes Workshop
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Salesforce Development Best Practices
Salesforce Development Best PracticesSalesforce Development Best Practices
Salesforce Development Best Practices
 
Frameworks Galore: A Pragmatic Review
Frameworks Galore: A Pragmatic ReviewFrameworks Galore: A Pragmatic Review
Frameworks Galore: A Pragmatic Review
 
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
44CON 2014 - Pentesting NoSQL DB's Using NoSQL Exploitation Framework, Franci...
 
Lecture #5 Introduction to rails
Lecture #5 Introduction to railsLecture #5 Introduction to rails
Lecture #5 Introduction to rails
 
Introduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy HinyukIntroduction to Rails by Evgeniy Hinyuk
Introduction to Rails by Evgeniy Hinyuk
 
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
 
Introduction to Laravel
Introduction to LaravelIntroduction to Laravel
Introduction to Laravel
 
SilverStripe From a Developer's Perspective
SilverStripe From a Developer's PerspectiveSilverStripe From a Developer's Perspective
SilverStripe From a Developer's Perspective
 
MySQL Day Paris 2016 - MySQL as a Document Store
MySQL Day Paris 2016 - MySQL as a Document StoreMySQL Day Paris 2016 - MySQL as a Document Store
MySQL Day Paris 2016 - MySQL as a Document Store
 
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
 
Salesforce Basic Development
Salesforce Basic DevelopmentSalesforce Basic Development
Salesforce Basic Development
 

Último

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 

Último (20)

SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 

Laravel ppt

  • 2. We will learn today • WHAT IS LARAVEL • INSTALL LARAVEL 5 WITH COMPOSER • FILES STRUCTURE • WHAT IS ARTISAN AND HOW DOES IT SAVE US TIME • ROUTING AND ROUTE TYPES • WHAT IS MIDDLEWARE AND HOW TO USE IT • WHAT IS BLADE ? • DATABASE AND ELOQUENT ORM • CRUD WITH VALIDATION AND DATABASE CONNECTION (PRACTICAL TASK) • BEST PRACTICES WHEN CODING IN LARAVEL
  • 3. • Laravel is MVC PHP framework created by Taylor Otwell in 2011 • Free open-source license with many contributors worldwide • One of the best frameworks together with Symfony, CodeIgniter, Yii • Has powerful features, saving us time • Uses Symfony packages What is
  • 4.
  • 5. • Eloquent ORM (object-relational mapping) – implements Active- Record • Query builder – helps you to build secured SQL queries • Restful controllers – provides a way for separating the different HTTP requests (GET, POST, DELETE, etc.) • Blade template engine – combines templates with a data model to produce views • Migrations – version control system for database, update your database easier • Database seeding – provides a way to populate database tables with test data used for testing • Pagination – easy to use advanced pagination functionalities • Forms security – provides CSRF token middleware, protecting all the forms Features of
  • 6. • Laravel uses Composer to manage its dependencies • Composer is dependency management tool for PHP, like a library full of books • NOT like Yum or apt • Per project tool (vendor folder), not per system • Install by using the command: composer create-project [PACKAGE] [DESTINATION PATH] [--FLAGS] composer create-project laravel/laravel Laravel test Let’s install
  • 7. app/Http folder contains the Controllers, Middlewares and Kernel file All the models should be located in app/Models folder All the config files are located in app/config folder The service providers that are bootstrapping functions in our app are located in app/Providers folder Folder Structure
  • 8. Folder Structure • Database folder contains the migrations and seeds • The public folder is the actual folder you are opening on the web server. All JS / CSS / Images / Uploads are located there. • The resources folder contains all the translations, views and assets (SASS, LESS, JS) that are compiled into public folder • The routes folder contains all the routes for the project • All the logs / cache files are located in storage folder • The vendor folder contains all the composer packages (dependencies)
  • 9. Artisan is command-line interface for Laravel Commands that are saving time Generating files with artisan is recommended Run php artisan list in the console Artisan!
  • 10. • The best and easy routing system I’ve seen • Routing per middleware / prefix or namespace • Routing per request method (GET, POST, DELETE, etc.) • ALWAYS name your route ! • Be careful with the routing order ! Let’s see routing examples Routing
  • 11. • The middleware is mechanism for filtering the HTTP requests • Laravel includes several middleware's – Authentication, CSRF Protection • The auth middleware checks if the user visiting the page is authenticated through session cookie • The CSRF token protection middleware protects your application from cross-site request forgery attacks by adding token key for each generated form Let’s create middleware Middleware
  • 12. • Blade is the powerful template engine provided by Laravel • All the code inside blade file is compiled to static html file • Supports plain PHP • Saves time • Better components mobility, extend and include partials Let’s take a look at few examples Blade
  • 13. ELOQUENT & DATABASE • THE ELOQUENT ORM (OBJECT-RELATIONAL MAPPING) PROVIDES SIMPLE ACTIVE RECORD IMPLEMENTATION FOR WORKING WITH THE DATABASE $article = new Article(); $article->title = ‘Article title’; $article->description = ‘Description’; $article->save(); INSERT INTO `article` (`title`, `description`) VALUES (‘Article title’, ‘Description’);
  • 14. • EACH TABLE HAS ITS OWN “MODEL”. YOU CAN USE THE MODEL TO READ, INSERT, UPDATE OR DELETE ROW FROM THE SPECIFIC TABLE • LET’S CHECK ONE MODEL
  • 16. Best practices in • NEVER write queries or model logic inside the controller! The controller job is to communicate with the model and pass data to the view.
  • 17. Extend and include partials. For example share the same form fields on 2 pages – add and edit Views mobility
  • 18. Always use the CSRF token protection that Laravel provides in forms you create, the hackers will not be able to spam your forms and database Forms security
  • 19. Be careful with the database architecture, always use the proper length for specific column and never forget the indexes for searchable columns Database architecture
  • 20. • Avoid the big query unless you really have to do it. The big query is hard to debug and understand. • You can merge the small queries into one to save the CPU time on server, but sometimes the query becomes way too big. Big Query
  • 21. Don’t forget to write comments for each method or complicated logic. The PHPDoc comments are helping the IDE to autosuggest easier and the developers to understand the piece of code Don’t forget the PHPDoc