Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
whoami 
• Ahmad Shah Hafizan Hamidin 
• 27 years old 
• Been developing for > 7 years 
• Laravel & Orchestra fanboy 
• htt...
So What is Laravel?
+ +
Why so many Laravel? 
laravel/laravel! 
The framework structure and boilerplate codes 
! 
laravel/framework! 
The core of ...
What do we need? 
• A webserver (Apache2/NGINX) 
• PHP 5.4 or above 
• Database engines (MySQL/PostgreSQL/MSSQL) 
• PHP mc...
Composer! 
• Remember PEAR? 
• Awesome PHP package management 
• Making developer lives easier 
• Manage application depen...
How to get Laravel?! 
via Laravel installer! 
> composer global require “laravel/installer=~1.1” 
> laravel new my-applica...
Laravel Setup 
• Make app/storage directory writable 
• Update public/.htaccess if you are using alias 
• Update app/confi...
M V C 
Eloquent, Blade and Controller
Laravel Routes 
• Handles the HTTP requests 
• GET, POST, PUT, PATCH, DELETE 
• All application routes are defined inside ...
Laravel Routes 
Route with Closure! 
Route::get(‘foobar’, function () { 
return ‘Welcome to FooBar!’; 
}); 
! 
Route with ...
Laravel Controllers 
• Handles the HTTP requests 
• GET, POST, PUT, PATCH, DELETE 
• Controllers are kept under app/contro...
Laravel Resourceful 
Controllers 
• Handles the HTTP requests 
• GET, POST, PUT, PATCH, DELETE 
• Predefine controller met...
Laravel Resourceful! 
Controllers 
Route with Resource Controller! 
Route::resource(‘foobar’, ‘FoobarController’);
Laravel Views 
• The presentation layer of an application 
• Can accept either vanilla PHP or Blade 
files 
• View files a...
Laravel Views 
Route with view! 
Route::get(‘foobar’, function () { 
return View::make(‘foobar’); 
});
Laravel Blade
Laravel Blade 
• Laravel default templating engine 
• Files need to use .blade.php extension 
• Driven by inheritance and ...
Laravel Blade 
Master layout! 
<!doctype html> 
… 
<body> 
@yield(‘content’) 
</body> 
</html> 
! 
Child layout! 
@extends...
Laravel Eloquent 
• Laravel ORM component 
• Simple ActiveRecord implementation 
• Each tables can be represented with a 
...
Laravel Fluent 
• Laravel SQL query builder component 
• Write SQL query in a more elegant and readable 
way
Laravel Filters 
• Control the behaviour of a route 
• Process request before or after 
• Filters are located inside app/f...
Laravel Auth 
• Laravel user authentication component 
• Provide a basic functionalities to authenticate users 
• Does not...
Tinkering with the artisan
Laravel Artisan 
• Laravel CLI 
• Uses the Symfony Console component 
• Manage table migrations, seed tables, 
create reso...
Service Providers & Facades
SOLID Principles 
Single Responsibility Principle! 
a class should have only one responsibility 
! 
Open/Closed Principle!...
SOLID Principles 
Interface Segregation Principle! 
many client-specific interfaces are better 
! 
Dependency Inversion Pr...
Laravel IOC 
• Inversion Of Control 
• Manages class dependencies 
• Based on dependency injection method 
• Dependencies ...
Laravel Service Providers 
• Act like a component bootstrap 
• Group related IoC registrations in one place 
• Can also ru...
Laravel Facades 
• Provide static interfaces to classes 
• Classes are resolved via IoC containers 
• Laravel is full with...
Laravel Workbench 
• A tool to help develop laravel based components 
• Scaffold the necessary boilerplates 
• We do not c...
Laravel Introduction
Laravel Introduction
Laravel Introduction
Upcoming SlideShare
Loading in …5
×

Laravel Introduction

7,471 views

Published on

Introduction to Laravel 4 framework

Published in: Technology

Laravel Introduction

  1. 1. whoami • Ahmad Shah Hafizan Hamidin • 27 years old • Been developing for > 7 years • Laravel & Orchestra fanboy • https://www.github.com/ahmadshah • @penjajah • kuasamalaya
  2. 2. So What is Laravel?
  3. 3. + +
  4. 4. Why so many Laravel? laravel/laravel! The framework structure and boilerplate codes ! laravel/framework! The core of laravel framework or the kernel ! Illuminate The namespace for every laravel framework components!
  5. 5. What do we need? • A webserver (Apache2/NGINX) • PHP 5.4 or above • Database engines (MySQL/PostgreSQL/MSSQL) • PHP mcrypt extension • Composer
  6. 6. Composer! • Remember PEAR? • Awesome PHP package management • Making developer lives easier • Manage application dependencies • http://getcomposer.org/ • http://packagist.com/
  7. 7. How to get Laravel?! via Laravel installer! > composer global require “laravel/installer=~1.1” > laravel new my-application ! via Composer! > composer create-project laravel/laravel my-application
  8. 8. Laravel Setup • Make app/storage directory writable • Update public/.htaccess if you are using alias • Update app/config/database.php to connect to your database
  9. 9. M V C Eloquent, Blade and Controller
  10. 10. Laravel Routes • Handles the HTTP requests • GET, POST, PUT, PATCH, DELETE • All application routes are defined inside app/routes.php • Can accept Closures or controller namespace
  11. 11. Laravel Routes Route with Closure! Route::get(‘foobar’, function () { return ‘Welcome to FooBar!’; }); ! Route with Controller! Route::get(‘foobar’, ‘FoobarController@index’);
  12. 12. Laravel Controllers • Handles the HTTP requests • GET, POST, PUT, PATCH, DELETE • Controllers are kept under app/controllers • Laravel naming convention: FoobarController • Extends IlluminateRoutingController class
  13. 13. Laravel 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
  14. 14. Laravel Resourceful! Controllers Route with Resource Controller! Route::resource(‘foobar’, ‘FoobarController’);
  15. 15. Laravel Views • The presentation layer of an application • Can accept either vanilla PHP or Blade files • View files are located under app/views directory • Can accept array arguments
  16. 16. Laravel Views Route with view! Route::get(‘foobar’, function () { return View::make(‘foobar’); });
  17. 17. Laravel Blade
  18. 18. Laravel Blade • Laravel default templating engine • Files need to use .blade.php extension • Driven by inheritance and sections • Extensible for adding new custom control structures
  19. 19. Laravel Blade Master layout! <!doctype html> … <body> @yield(‘content’) </body> </html> ! Child layout! @extends(‘layout.master’) @section(‘content’) … @stop
  20. 20. Laravel Eloquent • Laravel ORM component • Simple ActiveRecord implementation • Each tables can be represented with a “Model” file • Model files are located under app/models directory • Extends IlluminateDatabaseEloquentModel class
  21. 21. Laravel Fluent • Laravel SQL query builder component • Write SQL query in a more elegant and readable way
  22. 22. Laravel Filters • Control the behaviour of a route • Process request before or after • Filters are located inside app/filters.php • Can be attached directly to route or controller • Can be in either Closure or filter class
  23. 23. Laravel Auth • Laravel user authentication component • Provide a basic functionalities to authenticate users • Does not come with ACL / RBAC • Utilizes app/models/User.php • Laravel does not come with a user table by default
  24. 24. Tinkering with the artisan
  25. 25. Laravel Artisan • Laravel CLI • Uses the Symfony Console component • Manage table migrations, seed tables, create resourceful controllers and many more • Developer best friend!
  26. 26. Service Providers & Facades
  27. 27. SOLID Principles Single Responsibility Principle! a class should have only one responsibility ! Open/Closed Principle! open for extension and closed for modification ! Liskov Substitution Principle Subtypes must be substitutable for their base types!
  28. 28. SOLID Principles Interface Segregation Principle! many client-specific interfaces are better ! Dependency Inversion Principle! depends on abstraction ! !
  29. 29. Laravel IOC • Inversion Of Control • Manages class dependencies • Based on dependency injection method • Dependencies are injected at run-time • Allowing dependencies to be easily swapped
  30. 30. Laravel Service Providers • Act like a component bootstrap • Group related IoC registrations in one place • Can also run other functionalities like artisan commands
  31. 31. Laravel Facades • Provide static interfaces to classes • Classes are resolved via IoC containers • Laravel is full with facades such as View, Cache, Config and others
  32. 32. Laravel Workbench • A tool to help develop laravel based components • Scaffold the necessary boilerplates • We do not commit/ship workbench directory

×