2. 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
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
● 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
7. Route with Resource Controller
● Route::resource(‘user’, ‘UserController’);
Routes
8. 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
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 version control 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
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.
12. 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