By: Sita Prajapati
28Th
August, 2015
Free, Open Source PHP framework
Developers Taylor Otwell
Initial release June 2011
Stable release 5.1
Development status Active
Written in PHP5
Operating system Cross-platform
Type Web application framework
License MIT License
Website laravel.com
Introduction
Laravel
Introduction
Laravel
Other Frameworks Laravel
M ---------> Eloquent ORM
V ---------> Blade Engine
C ---------> Resourceful Controller
MVC
Command line interface
● Provides a number of commands php artisan list
Common uses
● Managing database migrations
and seeding
● Publishing package assets
● Generating boilerplate code for
controllers and migrations
Artisan
Resourceful Controllers
● Handles the HTTP requests (GET, POST, PUT, PATCH, DELETE).
● Predefine controller methods to handle the HTTP verbs (index, show,
create, store, edit, update, and destroy).
Controllers
Route with Resource Controller
● Route::resource(‘user’, ‘UserController’);
Routes
Eloquent ORM
Some examples of queries:
Book::all();
Book::find(1);
$b = new Book();
$b->title = 'Laravel Basics';
$b->description = 'Besr';
$b->save();
Scope
public function scopePopular($query) {
return $query->where('rating', '>', '4');
}
Book::popular()->get();
Accessor
public function getGenderAttribute($value){
return ($value == 'm') ? 'Male' : 'Female';
}
Mutator
public function setNameAttribute($value) {
$this->attributes['name'] = strtolower($value);
}
Built-in ORM
● Active Record style
● Easy to use
● Relationship mapping
● Supports soft delete
● Support query scope
● Supports accessors and mutators
Blade Engine
Examples:
@if (.....) @for(....)
... ...
@elseif @endfor
...
@else
…
@foreach (....)
. ...
@endforeach
My name is <?php echo $user->name ?>
My name is {{ $user->name }}
Blade templating
● Provide own control structures.
- Conditional statements
- Loops
● Alternative way to echo variable values.
● Fast in rendering page.
Migrations/Seeders
Migrations
● Provide version control systems for database schemas.
Seeders
● Populate database tables with selected default data.
● Can be used for testing or for initial application setup.
Inversion of Control
IoC container
● Describe your objects to the container, and every time you resolve a class
the dependencies are injected automatically.
● Core laravel is an IoC container.
● Holds instances of Request, Session, FormRequest etc.
Never Stop Learning
Where do I learn more?
laravel.com: docs, api, forums
http://laravel.io/: podcasts, news
Twitter, @laravelphp, @laracasts, @Laracasts_Forum, @laravelnews
IRC, http://laravel.io/irc
Paid
https://leanpub.com/laravel: Author's book
https://laracasts.com/: Has many free videos as well
https://leanpub.com/laravel-testing-decoded
Thank You
YOU
LEARN SOMETHING
EVERY DAY
IF YOU PAY
ATTENTION
Questions
Who is the creator of laravel?
Taylor Otwell

Laravel

  • 1.
  • 2.
    Free, Open SourcePHP framework Developers Taylor Otwell Initial release June 2011 Stable release 5.1 Development status Active Written in PHP5 Operating system Cross-platform Type Web application framework License MIT License Website laravel.com Introduction
  • 3.
  • 4.
    Other Frameworks Laravel M---------> Eloquent ORM V ---------> Blade Engine C ---------> Resourceful Controller MVC
  • 5.
    Command line interface ●Provides a number of commands php artisan list Common uses ● Managing database migrations and seeding ● Publishing package assets ● Generating boilerplate code for controllers and migrations Artisan
  • 6.
    Resourceful Controllers ● Handlesthe HTTP requests (GET, POST, PUT, PATCH, DELETE). ● Predefine controller methods to handle the HTTP verbs (index, show, create, store, edit, update, and destroy). Controllers
  • 7.
    Route with ResourceController ● Route::resource(‘user’, ‘UserController’); Routes
  • 8.
    Eloquent ORM Some examplesof queries: Book::all(); Book::find(1); $b = new Book(); $b->title = 'Laravel Basics'; $b->description = 'Besr'; $b->save(); Scope public function scopePopular($query) { return $query->where('rating', '>', '4'); } Book::popular()->get(); Accessor public function getGenderAttribute($value){ return ($value == 'm') ? 'Male' : 'Female'; } Mutator public function setNameAttribute($value) { $this->attributes['name'] = strtolower($value); } Built-in ORM ● Active Record style ● Easy to use ● Relationship mapping ● Supports soft delete ● Support query scope ● Supports accessors and mutators
  • 9.
    Blade Engine Examples: @if (.....)@for(....) ... ... @elseif @endfor ... @else … @foreach (....) . ... @endforeach My name is <?php echo $user->name ?> My name is {{ $user->name }} Blade templating ● Provide own control structures. - Conditional statements - Loops ● Alternative way to echo variable values. ● Fast in rendering page.
  • 10.
    Migrations/Seeders Migrations ● Provide versioncontrol systems for database schemas. Seeders ● Populate database tables with selected default data. ● Can be used for testing or for initial application setup.
  • 11.
    Inversion of Control IoCcontainer ● Describe your objects to the container, and every time you resolve a class the dependencies are injected automatically. ● Core laravel is an IoC container. ● Holds instances of Request, Session, FormRequest etc.
  • 12.
    Never Stop Learning Wheredo I learn more? laravel.com: docs, api, forums http://laravel.io/: podcasts, news Twitter, @laravelphp, @laracasts, @Laracasts_Forum, @laravelnews IRC, http://laravel.io/irc Paid https://leanpub.com/laravel: Author's book https://laracasts.com/: Has many free videos as well https://leanpub.com/laravel-testing-decoded
  • 13.
  • 14.
  • 15.
    Questions Who is thecreator of laravel? Taylor Otwell