SlideShare uma empresa Scribd logo
1 de 21
WHAT IS LARAVEL ?
Presented By
Dyuti Islam
151-15-5435
Section:B
CONTENTS …
 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
LERAVEL
 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
 Lets see some statistics
GOOGLE TRENDS (2012 – 2017)
PHP FRAMEWORK POPULARITY AT WORK – SITEPOINT 2015
FEATURES
 Eloquent ORM (object-relational mapping) – implements ActiveRecord
 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
MUST HAVE PACKAGES
 Laravel debugbar - https://github.com/barryvdh/laravel-debugbar
Great for debugging on local environment. Shows all the views, requests,
exceptions loaded for the current page.
 LaravelCollective – Forms & HTML -
https://laravelcollective.com/docs/master/html
Perfect for generating forms, inputs, script tags and style tags
 Laravel IDE Helper - https://github.com/barryvdh/laravel-ide-helper
The package helps your IDE with autocomplete and autosuggest methods, views,
functions and more.
LET’S INSTALL LARAVEL
 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 --prefer-dist laravel/laravel
laravel-softuni
THE STRUCTURE
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
ARTISAN !
 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
MIDDLEWARE
 The middleware is mechanism for
filtering the HTTP requests
 Laravel includes several middlewares
– Authentication, CSRF Protection
 The auth middleware checks if the
user visting 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
BLADE
 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
ELOQUENT & DATABASE
 The Eloquent ORM (Object-relational mapping) provides simple ActiveRecord
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
We will play with Laravel and create CRUD for recipes (Create, Read, Update,
Delete).
The recipe will have the following columns / fields :
• Id – primary key – not null
• Title – varchar – 255 length – not null
• Description – text – nullable
• Status – enum [ active / inactive ] – not null – defaults to active
• Created At – datetime – not null
• Updated At – datetime – not null
BEST PRACTICES IN LARAVEL
NEVER write queries or model logic inside the controller! The
controller job is to communicate with the model and pass data to
the view.
VIEWS MOBILITY
Extend and include partials. For example share the
same form fields on 2 pages – add and edit
FORMS SECURITY
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
BIG QUERY
• 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.
DON’T FORGET THE PHPDOC
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
THANK YOU! QUESTIONS ?

Mais conteúdo relacionado

Mais procurados

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
 
Web Development with Laravel 5
Web Development with Laravel 5Web Development with Laravel 5
Web Development with Laravel 5Soheil Khodayari
 
Lecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptxLecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptxSaziaRahman
 
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 ArtisansWindzoon Technologies
 
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
 
Laravel tutorial
Laravel tutorialLaravel tutorial
Laravel tutorialBroker IG
 
Laravel presentation
Laravel presentationLaravel presentation
Laravel presentationToufiq Mahmud
 
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...Edureka!
 
Html5 tutorial for beginners
Html5 tutorial for beginnersHtml5 tutorial for beginners
Html5 tutorial for beginnersSingsys Pte Ltd
 
Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1Vikas Chauhan
 
React.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOMReact.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOMJimit Shah
 
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
 
C# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENTC# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENTDr. Awase Khirni Syed
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to JavascriptAmit Tyagi
 

Mais procurados (20)

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
 
Web Development with Laravel 5
Web Development with Laravel 5Web Development with Laravel 5
Web Development with Laravel 5
 
Laravel ppt
Laravel pptLaravel ppt
Laravel ppt
 
Why Laravel?
Why Laravel?Why Laravel?
Why Laravel?
 
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
 
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 tutorial
Laravel tutorialLaravel tutorial
Laravel tutorial
 
Laravel presentation
Laravel presentationLaravel presentation
Laravel presentation
 
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...
 
Html5 tutorial for beginners
Html5 tutorial for beginnersHtml5 tutorial for beginners
Html5 tutorial for beginners
 
Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1
 
Selenium-Locators
Selenium-LocatorsSelenium-Locators
Selenium-Locators
 
React.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOMReact.js - The Dawn of Virtual DOM
React.js - The Dawn of Virtual DOM
 
AngularJS
AngularJS AngularJS
AngularJS
 
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
 
React js for beginners
React js for beginnersReact js for beginners
React js for beginners
 
C# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENTC# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENT
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
 
Introduction to Javascript
Introduction to JavascriptIntroduction to Javascript
Introduction to Javascript
 

Semelhante a Laravel

What’s New in Laravel 8 for a Laravel Development Company?
What’s New in Laravel 8 for a Laravel Development Company?What’s New in Laravel 8 for a Laravel Development Company?
What’s New in Laravel 8 for a Laravel Development Company?Inexture Solutions
 
Latest Laravel Practice 2023 Experts Guidance.pdf
Latest Laravel Practice 2023 Experts Guidance.pdfLatest Laravel Practice 2023 Experts Guidance.pdf
Latest Laravel Practice 2023 Experts Guidance.pdfSufalam Technologies
 
Laravel: Unleashing the power of PHP
Laravel: Unleashing the power  of PHPLaravel: Unleashing the power  of PHP
Laravel: Unleashing the power of PHPCetpa Infotech
 
Laravel Web Development: A Comprehensive Guide
Laravel Web Development: A Comprehensive GuideLaravel Web Development: A Comprehensive Guide
Laravel Web Development: A Comprehensive Guidedeep9753ak
 
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
 
laravel-interview-questions.pdf
laravel-interview-questions.pdflaravel-interview-questions.pdf
laravel-interview-questions.pdfAnuragMourya8
 
Why is Laravel the best framework for startups?
Why is Laravel the best framework for startups?Why is Laravel the best framework for startups?
Why is Laravel the best framework for startups?Sterling Technolabs
 
What makes Laravel the optimal framework for your project.pdf
What makes Laravel the optimal framework for your project.pdfWhat makes Laravel the optimal framework for your project.pdf
What makes Laravel the optimal framework for your project.pdfCubetTechnoLabs1
 
Lecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdfLecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdfShaimaaMohamedGalal
 
Unleashing the Power of Laravel A Journey to Modern Web Development | CETPA I...
Unleashing the Power of Laravel A Journey to Modern Web Development | CETPA I...Unleashing the Power of Laravel A Journey to Modern Web Development | CETPA I...
Unleashing the Power of Laravel A Journey to Modern Web Development | CETPA I...Cetpa Infotech
 
Laravel : A Fastest Growing Kid
Laravel : A Fastest Growing KidLaravel : A Fastest Growing Kid
Laravel : A Fastest Growing KidEndive Software
 
Why Laravel is the first choice for Web development_.pdf
Why Laravel is the first choice for Web development_.pdfWhy Laravel is the first choice for Web development_.pdf
Why Laravel is the first choice for Web development_.pdfMoon Technolabs Pvt. Ltd.
 

Semelhante a Laravel (20)

What’s New in Laravel 8 for a Laravel Development Company?
What’s New in Laravel 8 for a Laravel Development Company?What’s New in Laravel 8 for a Laravel Development Company?
What’s New in Laravel 8 for a Laravel Development Company?
 
Latest Laravel Practice 2023 Experts Guidance.pdf
Latest Laravel Practice 2023 Experts Guidance.pdfLatest Laravel Practice 2023 Experts Guidance.pdf
Latest Laravel Practice 2023 Experts Guidance.pdf
 
Web presentation
Web presentationWeb presentation
Web presentation
 
Laravel: Unleashing the power of PHP
Laravel: Unleashing the power  of PHPLaravel: Unleashing the power  of PHP
Laravel: Unleashing the power of PHP
 
Getting started with laravel
Getting started with laravelGetting started with laravel
Getting started with laravel
 
Laravel Web Development: A Comprehensive Guide
Laravel Web Development: A Comprehensive GuideLaravel Web Development: A Comprehensive Guide
Laravel Web Development: A Comprehensive Guide
 
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)
 
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
 
Who Should Consider Using Laravel for Web Development?
Who Should Consider Using Laravel for Web Development?Who Should Consider Using Laravel for Web Development?
Who Should Consider Using Laravel for Web Development?
 
Laravel Presentation
Laravel PresentationLaravel Presentation
Laravel Presentation
 
laravel-interview-questions.pdf
laravel-interview-questions.pdflaravel-interview-questions.pdf
laravel-interview-questions.pdf
 
Why is Laravel the best framework for startups?
Why is Laravel the best framework for startups?Why is Laravel the best framework for startups?
Why is Laravel the best framework for startups?
 
What makes Laravel the optimal framework for your project.pdf
What makes Laravel the optimal framework for your project.pdfWhat makes Laravel the optimal framework for your project.pdf
What makes Laravel the optimal framework for your project.pdf
 
Lecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdfLecture11_LaravelGetStarted_SPring2023.pdf
Lecture11_LaravelGetStarted_SPring2023.pdf
 
Article laravel 8
Article laravel 8Article laravel 8
Article laravel 8
 
Unleashing the Power of Laravel A Journey to Modern Web Development | CETPA I...
Unleashing the Power of Laravel A Journey to Modern Web Development | CETPA I...Unleashing the Power of Laravel A Journey to Modern Web Development | CETPA I...
Unleashing the Power of Laravel A Journey to Modern Web Development | CETPA I...
 
Laravel : A Fastest Growing Kid
Laravel : A Fastest Growing KidLaravel : A Fastest Growing Kid
Laravel : A Fastest Growing Kid
 
Why Laravel is the first choice for Web development_.pdf
Why Laravel is the first choice for Web development_.pdfWhy Laravel is the first choice for Web development_.pdf
Why Laravel is the first choice for Web development_.pdf
 
Laravel 9_ Unlock the Exciting Features Here!.pptx
Laravel 9_ Unlock the Exciting Features Here!.pptxLaravel 9_ Unlock the Exciting Features Here!.pptx
Laravel 9_ Unlock the Exciting Features Here!.pptx
 

Último

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 

Último (20)

INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 

Laravel

  • 1. WHAT IS LARAVEL ? Presented By Dyuti Islam 151-15-5435 Section:B
  • 2. CONTENTS …  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. LERAVEL  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  Lets see some statistics
  • 5. PHP FRAMEWORK POPULARITY AT WORK – SITEPOINT 2015
  • 6. FEATURES  Eloquent ORM (object-relational mapping) – implements ActiveRecord  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
  • 7. MUST HAVE PACKAGES  Laravel debugbar - https://github.com/barryvdh/laravel-debugbar Great for debugging on local environment. Shows all the views, requests, exceptions loaded for the current page.  LaravelCollective – Forms & HTML - https://laravelcollective.com/docs/master/html Perfect for generating forms, inputs, script tags and style tags  Laravel IDE Helper - https://github.com/barryvdh/laravel-ide-helper The package helps your IDE with autocomplete and autosuggest methods, views, functions and more.
  • 8. LET’S INSTALL LARAVEL  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 --prefer-dist laravel/laravel laravel-softuni
  • 9. THE STRUCTURE 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
  • 10. ARTISAN !  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
  • 11. MIDDLEWARE  The middleware is mechanism for filtering the HTTP requests  Laravel includes several middlewares – Authentication, CSRF Protection  The auth middleware checks if the user visting 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
  • 12. BLADE  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
  • 13. ELOQUENT & DATABASE  The Eloquent ORM (Object-relational mapping) provides simple ActiveRecord 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
  • 15. PRACTICAL TASK We will play with Laravel and create CRUD for recipes (Create, Read, Update, Delete). The recipe will have the following columns / fields : • Id – primary key – not null • Title – varchar – 255 length – not null • Description – text – nullable • Status – enum [ active / inactive ] – not null – defaults to active • Created At – datetime – not null • Updated At – datetime – not null
  • 16. BEST PRACTICES IN LARAVEL 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. VIEWS MOBILITY Extend and include partials. For example share the same form fields on 2 pages – add and edit
  • 18. FORMS SECURITY 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
  • 19. BIG QUERY • 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.
  • 20. DON’T FORGET THE PHPDOC 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