SlideShare a Scribd company logo
1 of 24
Download to read offline
1
Getting started with
Laravel
Presenter :
Nikhil Agrawal
Mindfire Solutions
Date: 22nd April, 2014
2
Zend PHP 5.3 Certified
OCA-1z0-870 - MySQL 5 Certified
DELF-A1-French Certified
Skills: Laravel, cakePHP, Codeigniter, Mysql, Jquery, HTML,
css
About me
Presenter: Nikhil Agrawal, Mindfire Solutions
Connect Me:
https://www.facebook.com/nkhl.agrawal
http://in.linkedin.com/pub/nikhil-agrawal/33/318/21b/
https://twitter.com/NikhilAgrawal44
Contact Me:
Email: nikhila@mindfiresolutions.com, nikhil_agrawal@live.com
Skype: mfsi_nikhila
3
Content
โœ” Introduction
โœ” Features
โœ” Setup
โœ” Artisan CLI
โœ” Routing
โœ” Controller, Model, View (MVC)
โœ” Installing packages
โœ” Migration
โœ” Error & Logging
โœ” References & QA
Presenter: Nikhil Agrawal, Mindfire Solutions
4
Introduction
โœ” Started by Taylor Otwell (a c# developer).
โœ” PHP V>= 5.3 based MVC framework.
โœ” Hugely inspired by other web framework including
frameworks in other language such as ROR,
ASP.NET and Sinatra
โœ” Composer-based
โœ” Has a command line interface called as Artisan
โœ” Current stable version available is 4.1
Presenter: Nikhil Agrawal, Mindfire Solutions
5
Features out-of-the-box
โœ” Flexible routing
โœ” Powerful ActiveRecord ORM
โœ” Migration and seeding
โœ” Queue driver
โœ” Cache driver
โœ” Command-Line Utility (Artisan)
โœ” Blade Template
โœ” Authentication driver
โœ” Pagination, Mail drivers, unit testing and many more
Presenter: Nikhil Agrawal, Mindfire Solutions
6
Setup
โœ” Install Composer
curl -sS https://getcomposer.org/installer | php
โœ” It is a dependency manager
โœ” What problem it solves?
โœ” composer.json, composer.lock files
โœ” Install laravel / create-project.
โœ” Folder structure
โœ” Request lifecycle
โœ” Configuration
Presenter: Nikhil Agrawal, Mindfire Solutions
7
Artisan
โœ” Artisan is a command-line interface tool to speed up
development process
โœ” Commands
โœ” List all commands : php artisan list
โœ” View help for a commands : php artisan help migrate
โœ” Start PHP server : php artisan serve
โœ” Interact with app : php artisan tinker
โœ” View routes : php artisan routes
โœ” And many more...
Presenter: Nikhil Agrawal, Mindfire Solutions
8
Routing
โœ” Basic Get/Post route
โœ” Route with parameter & https
โœ” Route to controller action
Route::get('/test', function() {
return 'Hello'
})
Route::get('/test/{id}', array('https', function() {
return 'Hello'
}));
Route::get('/test/{id}', array(
'uses' => 'UsersController@login',
'as' => 'login'
)
)
Presenter: Nikhil Agrawal, Mindfire Solutions
9
Routing cont..
โœ” Route group and prefixes
โœ” Route Model binding
โœ” Url of route:
โœ” $url = route('routeName', $param);
โœ” $url = action('ControllerName@method', $param)
Route::group(array('before' => 'auth|admin', 'prefix' => 'admin'), function (){
//Different routes
})
Binding a parameter to model
Route::model('user_id', 'User');
Route::get('user/profile/{user_id}', function(User $user){
return $user->firstname . ' ' . $user->lastname
})
Presenter: Nikhil Agrawal, Mindfire Solutions
10
Controller
โœ” Extends BaseController, which can be used to write logic
common througout application
โœ” RESTful controller
โœ” Defining route
Route::controller('users', 'UserController');
โœ” Methods name is prefixed with get/post HTTP verbs
โœ” Resource controller
โœ” Creating using artisan
โœ” Register in routes
โœ” Start using it
Presenter: Nikhil Agrawal, Mindfire Solutions
11
Model
โœ” Model are used to interact with database.
โœ” Each model corresponds to a table in db.
โœ” Two different ways to write queries
1. Using Query Builder
2. Using Eloquent ORM
Presenter: Nikhil Agrawal, Mindfire Solutions
12
Query Builder (Model)
โœ” SELECT
โœ”
$users = DB::table('users')->get();
โœ” INSERT
โœ” $id = DB::table('user')
->insertGetId(array('email' =>'nikhila@mindfire.com',
'password' => 'mindfire'));
โœ” UPDATE
โœ” DB::table('users')
->where('active', '=', 0)
->update(array('active' => 1));
โœ” DELETE
โœ” DB::table('users')
->delete();
Presenter: Nikhil Agrawal, Mindfire Solutions
13
Eloquent ORM (Model)
โœ” Defining a Eloquent model
โœ” Class User Extends Eloquent { }
โœ” Try to keep the table name plural and the respective model as singular (e.g
users / User)
โœ” SELECT
โœ” $user = User::find(1) //Using Primary key
โœ” $user = User::findorfail(1) //Throws ModelNotFoundException if
no data is found
โœ” $user = Menu::where('group', '=', 'admin')->remember(10)->get();
//Caches Query for 10 minutes
โœ” INSERT
โœ” $user_obj = new User();
$user_obj->name = 'nikhil';
$user_obj->save();
โœ” $user = User::create(array('name' => 'nikhil'));
14
Query Scope (Eloquent ORM)
โœ” Allow re-use of logic in model.
Presenter: Nikhil Agrawal, Mindfire Solutions
15
Many others Eloquent features..
โœ” Defining Relationships
โœ” Soft deleting
โœ” Mass Assignment
โœ” Model events
โœ” Model observer
โœ” Eager loading
โœ” Accessors & Mutators
16
View (Blade Template)
Presenter: Nikhil Agrawal, Mindfire Solutions
17
Loops
View Composer
โœ” View composers are callbacks or class methods that are called when
a view is rendered.
โœ” If you have data that you want bound to a given view each time that
view is rendered throughout your application, a view composer can
organize that code into a single location
View::composer('displayTags', function($view)
{
$view->with('tags', Tag::all());
});
Presenter: Nikhil Agrawal, Mindfire Solutions
18
Installing packages
โœ” Installing a new package:
โœ” composer require <packageName> (Press Enter)
โœ” Give version information
โœ” Using composer.json/composer.lock files
โœ” composer install
โœ” Some useful packages
โœ” Sentry 2 for ACL implementation
โœ” bllim/datatables for Datatables
โœ” Way/Generators for speedup development process
โœ” barryvdh/laravel-debugbar
โœ” Check packagist.org for more list of packages
Presenter: Nikhil Agrawal, Mindfire Solutions
19
Migration
Developer A
โœ” Generate migration class
โœ” Run migration up
โœ” Commits file
Developer B
โœ” Pull changes from scm
โœ” Run migration up
1. Install migration
โœ” php artisan migrate install
2. Create migration using
โœ” php artisan migrate:make name
3. Run migration
โœ” php artisan migrate
4. Refresh, Reset, Rollback migration
Presenter: Nikhil Agrawal, Mindfire Solutions
Steps
20
Error & Logging
โœ” Enable/Disable debug error in app/config/app.php
โœ” Configure error log in app/start/global.php
โœ” Use Daily based log file or on single log file
โœ” Handle 404 Error
App::missing(function($exception){
return Response::view('errors.missing');
});
โœ” Handling fatal error
App::fatal(function($exception){
return "Fatal Error";
});
โœ” Generate HTTP exception using
App:abort(403);
โœ” Logging error
โœ” Log::warning('Somehting is going wrong'); //Info,error
21
References
โ— http://laravel.com/docs (Official Documentation)
โ— https://getcomposer.org/doc/00-intro.md (composer)
โ— https://laracasts.com/ (Video tutorials)
โ— http://cheats.jesse-obrien.ca/ (Cheat Sheet)
โ— http://taylorotwell.com/
Presenter: Nikhil Agrawal, Mindfire Solutions
22
Questions ??
Presenter: Nikhil Agrawal, Mindfire Solutions
23
A Big
Thank you !
Presenter: Nikhil Agrawal, Mindfire Solutions
24
Connect Us @
www.mindfiresolutions.com
https://www.facebook.com/MindfireSolutions
http://www.linkedin.com/company/mindfire-
solutions
http://twitter.com/mindfires

More Related Content

What's hot

Gerrit JavaScript Plugins
Gerrit JavaScript PluginsGerrit JavaScript Plugins
Gerrit JavaScript PluginsDariusz ลuksza
ย 
Let Grunt do the work, focus on the fun!
Let Grunt do the work, focus on the fun!Let Grunt do the work, focus on the fun!
Let Grunt do the work, focus on the fun!Dirk Ginader
ย 
็ฌฌ1ๅ›žๅๅคๅฑ‹Grails/Groogyๅ‹‰ๅผทไผšใ€ŒGrailsใ‚’ๅง‹ใ‚ใฆใฟใ‚ˆใ†!ใ€
็ฌฌ1ๅ›žๅๅคๅฑ‹Grails/Groogyๅ‹‰ๅผทไผšใ€ŒGrailsใ‚’ๅง‹ใ‚ใฆใฟใ‚ˆใ†!ใ€็ฌฌ1ๅ›žๅๅคๅฑ‹Grails/Groogyๅ‹‰ๅผทไผšใ€ŒGrailsใ‚’ๅง‹ใ‚ใฆใฟใ‚ˆใ†!ใ€
็ฌฌ1ๅ›žๅๅคๅฑ‹Grails/Groogyๅ‹‰ๅผทไผšใ€ŒGrailsใ‚’ๅง‹ใ‚ใฆใฟใ‚ˆใ†!ใ€Tsuyoshi Yamamoto
ย 
JS performance tools
JS performance toolsJS performance tools
JS performance toolsDmytro Ovcharenko
ย 
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]Dirk Ginader
ย 
Test Driven Infrastructure with Docker, Test Kitchen and Serverspec
Test Driven Infrastructure with Docker, Test Kitchen and ServerspecTest Driven Infrastructure with Docker, Test Kitchen and Serverspec
Test Driven Infrastructure with Docker, Test Kitchen and ServerspecYury Tsarev
ย 
Presentation security automation (Selenium Camp)
Presentation security automation (Selenium Camp)Presentation security automation (Selenium Camp)
Presentation security automation (Selenium Camp)Artyom Rozumenko
ย 
Automated Deployments
Automated DeploymentsAutomated Deployments
Automated DeploymentsMartin Etmajer
ย 
Groovy in the Cloud
Groovy in the CloudGroovy in the Cloud
Groovy in the CloudDaniel Woods
ย 
Continuos integration for iOS projects
Continuos integration for iOS projectsContinuos integration for iOS projects
Continuos integration for iOS projectsAleksandra Gavrilovska
ย 
COSCUP 2020 Google ๆŠ€่ก“ x ๅ…ฌๅ…ฑๅƒ่ˆ‡ x ้–‹ๆบ ๅฃ็ฝฉๅœฐๅœ–ๆŠ€่ก“้–‹ๆบ
COSCUP 2020 Google ๆŠ€่ก“ x ๅ…ฌๅ…ฑๅƒ่ˆ‡ x ้–‹ๆบ ๅฃ็ฝฉๅœฐๅœ–ๆŠ€่ก“้–‹ๆบCOSCUP 2020 Google ๆŠ€่ก“ x ๅ…ฌๅ…ฑๅƒ่ˆ‡ x ้–‹ๆบ ๅฃ็ฝฉๅœฐๅœ–ๆŠ€่ก“้–‹ๆบ
COSCUP 2020 Google ๆŠ€่ก“ x ๅ…ฌๅ…ฑๅƒ่ˆ‡ x ้–‹ๆบ ๅฃ็ฝฉๅœฐๅœ–ๆŠ€่ก“้–‹ๆบKAI CHU CHUNG
ย 
Gearman work queue in php
Gearman work queue in phpGearman work queue in php
Gearman work queue in phpBo-Yi Wu
ย 

What's hot (18)

Gerrit JavaScript Plugins
Gerrit JavaScript PluginsGerrit JavaScript Plugins
Gerrit JavaScript Plugins
ย 
Let Grunt do the work, focus on the fun!
Let Grunt do the work, focus on the fun!Let Grunt do the work, focus on the fun!
Let Grunt do the work, focus on the fun!
ย 
็ฌฌ1ๅ›žๅๅคๅฑ‹Grails/Groogyๅ‹‰ๅผทไผšใ€ŒGrailsใ‚’ๅง‹ใ‚ใฆใฟใ‚ˆใ†!ใ€
็ฌฌ1ๅ›žๅๅคๅฑ‹Grails/Groogyๅ‹‰ๅผทไผšใ€ŒGrailsใ‚’ๅง‹ใ‚ใฆใฟใ‚ˆใ†!ใ€็ฌฌ1ๅ›žๅๅคๅฑ‹Grails/Groogyๅ‹‰ๅผทไผšใ€ŒGrailsใ‚’ๅง‹ใ‚ใฆใฟใ‚ˆใ†!ใ€
็ฌฌ1ๅ›žๅๅคๅฑ‹Grails/Groogyๅ‹‰ๅผทไผšใ€ŒGrailsใ‚’ๅง‹ใ‚ใฆใฟใ‚ˆใ†!ใ€
ย 
JS performance tools
JS performance toolsJS performance tools
JS performance tools
ย 
jQuery plugin & testing with Jasmine
jQuery plugin & testing with JasminejQuery plugin & testing with Jasmine
jQuery plugin & testing with Jasmine
ย 
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
Let Grunt do the work, focus on the fun! [Open Web Camp 2013]
ย 
Introducing spring
Introducing springIntroducing spring
Introducing spring
ย 
Test Driven Infrastructure with Docker, Test Kitchen and Serverspec
Test Driven Infrastructure with Docker, Test Kitchen and ServerspecTest Driven Infrastructure with Docker, Test Kitchen and Serverspec
Test Driven Infrastructure with Docker, Test Kitchen and Serverspec
ย 
Go Revel Gooo...
Go Revel Gooo...Go Revel Gooo...
Go Revel Gooo...
ย 
Presentation security automation (Selenium Camp)
Presentation security automation (Selenium Camp)Presentation security automation (Selenium Camp)
Presentation security automation (Selenium Camp)
ย 
Plack at OSCON 2010
Plack at OSCON 2010Plack at OSCON 2010
Plack at OSCON 2010
ย 
Automated Deployments
Automated DeploymentsAutomated Deployments
Automated Deployments
ย 
Gradle
GradleGradle
Gradle
ย 
Tatsumaki
TatsumakiTatsumaki
Tatsumaki
ย 
Groovy in the Cloud
Groovy in the CloudGroovy in the Cloud
Groovy in the Cloud
ย 
Continuos integration for iOS projects
Continuos integration for iOS projectsContinuos integration for iOS projects
Continuos integration for iOS projects
ย 
COSCUP 2020 Google ๆŠ€่ก“ x ๅ…ฌๅ…ฑๅƒ่ˆ‡ x ้–‹ๆบ ๅฃ็ฝฉๅœฐๅœ–ๆŠ€่ก“้–‹ๆบ
COSCUP 2020 Google ๆŠ€่ก“ x ๅ…ฌๅ…ฑๅƒ่ˆ‡ x ้–‹ๆบ ๅฃ็ฝฉๅœฐๅœ–ๆŠ€่ก“้–‹ๆบCOSCUP 2020 Google ๆŠ€่ก“ x ๅ…ฌๅ…ฑๅƒ่ˆ‡ x ้–‹ๆบ ๅฃ็ฝฉๅœฐๅœ–ๆŠ€่ก“้–‹ๆบ
COSCUP 2020 Google ๆŠ€่ก“ x ๅ…ฌๅ…ฑๅƒ่ˆ‡ x ้–‹ๆบ ๅฃ็ฝฉๅœฐๅœ–ๆŠ€่ก“้–‹ๆบ
ย 
Gearman work queue in php
Gearman work queue in phpGearman work queue in php
Gearman work queue in php
ย 

Similar to Getting started-with-laravel

SF Grails - Ratpack - Compact Groovy Webapps - James Williams
SF Grails - Ratpack - Compact Groovy Webapps - James WilliamsSF Grails - Ratpack - Compact Groovy Webapps - James Williams
SF Grails - Ratpack - Compact Groovy Webapps - James WilliamsPhilip Stehlik
ย 
Pyramid Deployment and Maintenance
Pyramid Deployment and MaintenancePyramid Deployment and Maintenance
Pyramid Deployment and MaintenanceJazkarta, Inc.
ย 
Panmind at Ruby Social Club Milano
Panmind at Ruby Social Club MilanoPanmind at Ruby Social Club Milano
Panmind at Ruby Social Club MilanoPanmind
ย 
Let's build Developer Portal with Backstage
Let's build Developer Portal with BackstageLet's build Developer Portal with Backstage
Let's build Developer Portal with BackstageOpsta
ย 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!David Gibbons
ย 
Kubernetes walkthrough
Kubernetes walkthroughKubernetes walkthrough
Kubernetes walkthroughSangwon Lee
ย 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5Darren Craig
ย 
Ahmadabad mule soft_meetup_6march2021_azure_CICD
Ahmadabad mule soft_meetup_6march2021_azure_CICDAhmadabad mule soft_meetup_6march2021_azure_CICD
Ahmadabad mule soft_meetup_6march2021_azure_CICDShekh Muenuddeen
ย 
Catalyst patterns-yapc-eu-2016
Catalyst patterns-yapc-eu-2016Catalyst patterns-yapc-eu-2016
Catalyst patterns-yapc-eu-2016John Napiorkowski
ย 
What the heck went wrong?
What the heck went wrong?What the heck went wrong?
What the heck went wrong?Andy McKay
ย 
Go swagger tutorial how to create golang api documentation using go swagger (1)
Go swagger tutorial how to create golang api documentation using go swagger (1)Go swagger tutorial how to create golang api documentation using go swagger (1)
Go swagger tutorial how to create golang api documentation using go swagger (1)Katy Slemon
ย 
Sprint 71
Sprint 71Sprint 71
Sprint 71ManageIQ
ย 
Working with AngularJS
Working with AngularJSWorking with AngularJS
Working with AngularJSAndrรฉ Vala
ย 
Services Drupalcamp Stockholm 2009
Services Drupalcamp Stockholm 2009Services Drupalcamp Stockholm 2009
Services Drupalcamp Stockholm 2009hugowetterberg
ย 
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)cgmonroe
ย 
OpenStack Rally presentation by RamaK
OpenStack Rally presentation by RamaKOpenStack Rally presentation by RamaK
OpenStack Rally presentation by RamaKRama Krishna B
ย 
New features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptx
New features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptxNew features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptx
New features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptxMuralidharan Deenathayalan
ย 
Front end development with Angular JS
Front end development with Angular JSFront end development with Angular JS
Front end development with Angular JSBipin
ย 

Similar to Getting started-with-laravel (20)

SF Grails - Ratpack - Compact Groovy Webapps - James Williams
SF Grails - Ratpack - Compact Groovy Webapps - James WilliamsSF Grails - Ratpack - Compact Groovy Webapps - James Williams
SF Grails - Ratpack - Compact Groovy Webapps - James Williams
ย 
Pyramid Deployment and Maintenance
Pyramid Deployment and MaintenancePyramid Deployment and Maintenance
Pyramid Deployment and Maintenance
ย 
Panmind at Ruby Social Club Milano
Panmind at Ruby Social Club MilanoPanmind at Ruby Social Club Milano
Panmind at Ruby Social Club Milano
ย 
Let's build Developer Portal with Backstage
Let's build Developer Portal with BackstageLet's build Developer Portal with Backstage
Let's build Developer Portal with Backstage
ย 
How to Webpack your Django!
How to Webpack your Django!How to Webpack your Django!
How to Webpack your Django!
ย 
Kubernetes walkthrough
Kubernetes walkthroughKubernetes walkthrough
Kubernetes walkthrough
ย 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5
ย 
Ahmadabad mule soft_meetup_6march2021_azure_CICD
Ahmadabad mule soft_meetup_6march2021_azure_CICDAhmadabad mule soft_meetup_6march2021_azure_CICD
Ahmadabad mule soft_meetup_6march2021_azure_CICD
ย 
Catalyst patterns-yapc-eu-2016
Catalyst patterns-yapc-eu-2016Catalyst patterns-yapc-eu-2016
Catalyst patterns-yapc-eu-2016
ย 
What the heck went wrong?
What the heck went wrong?What the heck went wrong?
What the heck went wrong?
ย 
Go swagger tutorial how to create golang api documentation using go swagger (1)
Go swagger tutorial how to create golang api documentation using go swagger (1)Go swagger tutorial how to create golang api documentation using go swagger (1)
Go swagger tutorial how to create golang api documentation using go swagger (1)
ย 
Sprint 71
Sprint 71Sprint 71
Sprint 71
ย 
Working with AngularJS
Working with AngularJSWorking with AngularJS
Working with AngularJS
ย 
Pyramid patterns
Pyramid patternsPyramid patterns
Pyramid patterns
ย 
Services Drupalcamp Stockholm 2009
Services Drupalcamp Stockholm 2009Services Drupalcamp Stockholm 2009
Services Drupalcamp Stockholm 2009
ย 
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
Tips on Securing Drupal Sites - DrupalCamp Atlanta (DCA)
ย 
OpenStack Rally presentation by RamaK
OpenStack Rally presentation by RamaKOpenStack Rally presentation by RamaK
OpenStack Rally presentation by RamaK
ย 
New features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptx
New features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptxNew features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptx
New features of Minimal APIs in .NET 7 -Muralidharan Deenathayalan.pptx
ย 
Front end development with Angular JS
Front end development with Angular JSFront end development with Angular JS
Front end development with Angular JS
ย 
Pyramid deployment
Pyramid deploymentPyramid deployment
Pyramid deployment
ย 

Recently uploaded

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
ย 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
ย 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto Gonzรกlez Trastoy
ย 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
ย 
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online โ˜‚๏ธ
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online  โ˜‚๏ธCALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online  โ˜‚๏ธ
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online โ˜‚๏ธanilsa9823
ย 
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE9953056974 Low Rate Call Girls In Saket, Delhi NCR
ย 
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female service
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female serviceCALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female service
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
ย 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlanโ€™s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlanโ€™s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlanโ€™s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlanโ€™s ...OnePlan Solutions
ย 
Shapes for Sharing between Graph Data Spacesย - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spacesย - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spacesย - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spacesย - and Epistemic Querying of RDF-...Steffen Staab
ย 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
ย 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
ย 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
ย 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
ย 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfWilly Marroquin (WillyDevNET)
ย 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
ย 
call girls in Vaishali (Ghaziabad) ๐Ÿ” >เผ’8448380779 ๐Ÿ” genuine Escort Service ๐Ÿ”โœ”๏ธโœ”๏ธ
call girls in Vaishali (Ghaziabad) ๐Ÿ” >เผ’8448380779 ๐Ÿ” genuine Escort Service ๐Ÿ”โœ”๏ธโœ”๏ธcall girls in Vaishali (Ghaziabad) ๐Ÿ” >เผ’8448380779 ๐Ÿ” genuine Escort Service ๐Ÿ”โœ”๏ธโœ”๏ธ
call girls in Vaishali (Ghaziabad) ๐Ÿ” >เผ’8448380779 ๐Ÿ” genuine Escort Service ๐Ÿ”โœ”๏ธโœ”๏ธDelhi Call girls
ย 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
ย 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
ย 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
ย 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
ย 

Recently uploaded (20)

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
ย 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
ย 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
ย 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
ย 
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online โ˜‚๏ธ
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online  โ˜‚๏ธCALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online  โ˜‚๏ธ
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Kakori Lucknow best sexual service Online โ˜‚๏ธ
ย 
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )๐Ÿ” 9953056974๐Ÿ”(=)/CALL GIRLS SERVICE
ย 
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female service
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female serviceCALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female service
CALL ON โžฅ8923113531 ๐Ÿ”Call Girls Badshah Nagar Lucknow best Female service
ย 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlanโ€™s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlanโ€™s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlanโ€™s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlanโ€™s ...
ย 
Shapes for Sharing between Graph Data Spacesย - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spacesย - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spacesย - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spacesย - and Epistemic Querying of RDF-...
ย 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
ย 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
ย 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
ย 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
ย 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
ย 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
ย 
call girls in Vaishali (Ghaziabad) ๐Ÿ” >เผ’8448380779 ๐Ÿ” genuine Escort Service ๐Ÿ”โœ”๏ธโœ”๏ธ
call girls in Vaishali (Ghaziabad) ๐Ÿ” >เผ’8448380779 ๐Ÿ” genuine Escort Service ๐Ÿ”โœ”๏ธโœ”๏ธcall girls in Vaishali (Ghaziabad) ๐Ÿ” >เผ’8448380779 ๐Ÿ” genuine Escort Service ๐Ÿ”โœ”๏ธโœ”๏ธ
call girls in Vaishali (Ghaziabad) ๐Ÿ” >เผ’8448380779 ๐Ÿ” genuine Escort Service ๐Ÿ”โœ”๏ธโœ”๏ธ
ย 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
ย 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
ย 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
ย 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
ย 

Getting started-with-laravel

  • 1. 1 Getting started with Laravel Presenter : Nikhil Agrawal Mindfire Solutions Date: 22nd April, 2014
  • 2. 2 Zend PHP 5.3 Certified OCA-1z0-870 - MySQL 5 Certified DELF-A1-French Certified Skills: Laravel, cakePHP, Codeigniter, Mysql, Jquery, HTML, css About me Presenter: Nikhil Agrawal, Mindfire Solutions Connect Me: https://www.facebook.com/nkhl.agrawal http://in.linkedin.com/pub/nikhil-agrawal/33/318/21b/ https://twitter.com/NikhilAgrawal44 Contact Me: Email: nikhila@mindfiresolutions.com, nikhil_agrawal@live.com Skype: mfsi_nikhila
  • 3. 3 Content โœ” Introduction โœ” Features โœ” Setup โœ” Artisan CLI โœ” Routing โœ” Controller, Model, View (MVC) โœ” Installing packages โœ” Migration โœ” Error & Logging โœ” References & QA Presenter: Nikhil Agrawal, Mindfire Solutions
  • 4. 4 Introduction โœ” Started by Taylor Otwell (a c# developer). โœ” PHP V>= 5.3 based MVC framework. โœ” Hugely inspired by other web framework including frameworks in other language such as ROR, ASP.NET and Sinatra โœ” Composer-based โœ” Has a command line interface called as Artisan โœ” Current stable version available is 4.1 Presenter: Nikhil Agrawal, Mindfire Solutions
  • 5. 5 Features out-of-the-box โœ” Flexible routing โœ” Powerful ActiveRecord ORM โœ” Migration and seeding โœ” Queue driver โœ” Cache driver โœ” Command-Line Utility (Artisan) โœ” Blade Template โœ” Authentication driver โœ” Pagination, Mail drivers, unit testing and many more Presenter: Nikhil Agrawal, Mindfire Solutions
  • 6. 6 Setup โœ” Install Composer curl -sS https://getcomposer.org/installer | php โœ” It is a dependency manager โœ” What problem it solves? โœ” composer.json, composer.lock files โœ” Install laravel / create-project. โœ” Folder structure โœ” Request lifecycle โœ” Configuration Presenter: Nikhil Agrawal, Mindfire Solutions
  • 7. 7 Artisan โœ” Artisan is a command-line interface tool to speed up development process โœ” Commands โœ” List all commands : php artisan list โœ” View help for a commands : php artisan help migrate โœ” Start PHP server : php artisan serve โœ” Interact with app : php artisan tinker โœ” View routes : php artisan routes โœ” And many more... Presenter: Nikhil Agrawal, Mindfire Solutions
  • 8. 8 Routing โœ” Basic Get/Post route โœ” Route with parameter & https โœ” Route to controller action Route::get('/test', function() { return 'Hello' }) Route::get('/test/{id}', array('https', function() { return 'Hello' })); Route::get('/test/{id}', array( 'uses' => 'UsersController@login', 'as' => 'login' ) ) Presenter: Nikhil Agrawal, Mindfire Solutions
  • 9. 9 Routing cont.. โœ” Route group and prefixes โœ” Route Model binding โœ” Url of route: โœ” $url = route('routeName', $param); โœ” $url = action('ControllerName@method', $param) Route::group(array('before' => 'auth|admin', 'prefix' => 'admin'), function (){ //Different routes }) Binding a parameter to model Route::model('user_id', 'User'); Route::get('user/profile/{user_id}', function(User $user){ return $user->firstname . ' ' . $user->lastname }) Presenter: Nikhil Agrawal, Mindfire Solutions
  • 10. 10 Controller โœ” Extends BaseController, which can be used to write logic common througout application โœ” RESTful controller โœ” Defining route Route::controller('users', 'UserController'); โœ” Methods name is prefixed with get/post HTTP verbs โœ” Resource controller โœ” Creating using artisan โœ” Register in routes โœ” Start using it Presenter: Nikhil Agrawal, Mindfire Solutions
  • 11. 11 Model โœ” Model are used to interact with database. โœ” Each model corresponds to a table in db. โœ” Two different ways to write queries 1. Using Query Builder 2. Using Eloquent ORM Presenter: Nikhil Agrawal, Mindfire Solutions
  • 12. 12 Query Builder (Model) โœ” SELECT โœ” $users = DB::table('users')->get(); โœ” INSERT โœ” $id = DB::table('user') ->insertGetId(array('email' =>'nikhila@mindfire.com', 'password' => 'mindfire')); โœ” UPDATE โœ” DB::table('users') ->where('active', '=', 0) ->update(array('active' => 1)); โœ” DELETE โœ” DB::table('users') ->delete(); Presenter: Nikhil Agrawal, Mindfire Solutions
  • 13. 13 Eloquent ORM (Model) โœ” Defining a Eloquent model โœ” Class User Extends Eloquent { } โœ” Try to keep the table name plural and the respective model as singular (e.g users / User) โœ” SELECT โœ” $user = User::find(1) //Using Primary key โœ” $user = User::findorfail(1) //Throws ModelNotFoundException if no data is found โœ” $user = Menu::where('group', '=', 'admin')->remember(10)->get(); //Caches Query for 10 minutes โœ” INSERT โœ” $user_obj = new User(); $user_obj->name = 'nikhil'; $user_obj->save(); โœ” $user = User::create(array('name' => 'nikhil'));
  • 14. 14 Query Scope (Eloquent ORM) โœ” Allow re-use of logic in model. Presenter: Nikhil Agrawal, Mindfire Solutions
  • 15. 15 Many others Eloquent features.. โœ” Defining Relationships โœ” Soft deleting โœ” Mass Assignment โœ” Model events โœ” Model observer โœ” Eager loading โœ” Accessors & Mutators
  • 16. 16 View (Blade Template) Presenter: Nikhil Agrawal, Mindfire Solutions
  • 17. 17 Loops View Composer โœ” View composers are callbacks or class methods that are called when a view is rendered. โœ” If you have data that you want bound to a given view each time that view is rendered throughout your application, a view composer can organize that code into a single location View::composer('displayTags', function($view) { $view->with('tags', Tag::all()); }); Presenter: Nikhil Agrawal, Mindfire Solutions
  • 18. 18 Installing packages โœ” Installing a new package: โœ” composer require <packageName> (Press Enter) โœ” Give version information โœ” Using composer.json/composer.lock files โœ” composer install โœ” Some useful packages โœ” Sentry 2 for ACL implementation โœ” bllim/datatables for Datatables โœ” Way/Generators for speedup development process โœ” barryvdh/laravel-debugbar โœ” Check packagist.org for more list of packages Presenter: Nikhil Agrawal, Mindfire Solutions
  • 19. 19 Migration Developer A โœ” Generate migration class โœ” Run migration up โœ” Commits file Developer B โœ” Pull changes from scm โœ” Run migration up 1. Install migration โœ” php artisan migrate install 2. Create migration using โœ” php artisan migrate:make name 3. Run migration โœ” php artisan migrate 4. Refresh, Reset, Rollback migration Presenter: Nikhil Agrawal, Mindfire Solutions Steps
  • 20. 20 Error & Logging โœ” Enable/Disable debug error in app/config/app.php โœ” Configure error log in app/start/global.php โœ” Use Daily based log file or on single log file โœ” Handle 404 Error App::missing(function($exception){ return Response::view('errors.missing'); }); โœ” Handling fatal error App::fatal(function($exception){ return "Fatal Error"; }); โœ” Generate HTTP exception using App:abort(403); โœ” Logging error โœ” Log::warning('Somehting is going wrong'); //Info,error
  • 21. 21 References โ— http://laravel.com/docs (Official Documentation) โ— https://getcomposer.org/doc/00-intro.md (composer) โ— https://laracasts.com/ (Video tutorials) โ— http://cheats.jesse-obrien.ca/ (Cheat Sheet) โ— http://taylorotwell.com/ Presenter: Nikhil Agrawal, Mindfire Solutions
  • 22. 22 Questions ?? Presenter: Nikhil Agrawal, Mindfire Solutions
  • 23. 23 A Big Thank you ! Presenter: Nikhil Agrawal, Mindfire Solutions