• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Memphis php 01 22-13 - laravel basics
 

Memphis php 01 22-13 - laravel basics

on

  • 2,324 views

Slides from http://www.memphisphp.org/events/93611422/ Memphis PHP user group meeting talking about the basics of the PHP Framework Laravel.

Slides from http://www.memphisphp.org/events/93611422/ Memphis PHP user group meeting talking about the basics of the PHP Framework Laravel.

Statistics

Views

Total Views
2,324
Views on SlideShare
2,324
Embed Views
0

Actions

Likes
0
Downloads
74
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Memphis php 01 22-13 - laravel basics Memphis php 01 22-13 - laravel basics Presentation Transcript

    • Laravel Basics MemphisPHP.org 01-22-13Tonights Sponsor:
    • What is Laravel?● MVC PHP Framework● Created in April 2011● Incredibly well documented● "A framework for Web Artisans"● Ease of entry● Something for everyone ○ emphasizes flexibility and expressiveness.
    • What makes Laravel different?● Bundles ○ Laravels Package System ○ Easily add plugins to your project ○ Easily share your code with others● Eloquent ORM ○ Not everyone is a DBA ○ Using PHP ActiveRecord ○ Takes advantage of Fluent Query Builder ■ Uses prepared statements ■ Automatic defense against SQL injection● Flexible Application Logic ○ Route using controllers or directly via routes
    • What makes Laravel different?● RESTful controllers ○ Easily separate GET and POST requests● Class Autoloading ○ Just use your class, laravel takes care of the loading ○ Only required classes are loaded for each request● Migrations ○ Version control for your database schema● Unit Testing - PHPUnit tightly integrated● Automatic pagination● Reverse Routing ○ Easily change routes down the road ○ Using route names prevents broken links / routes
    • Laravel Project Structure/application - Most of your Application Code/bundles - Laravel Applications (plugins)/laravel - Core Framework Files/public - Webserver Document Root/storage - File store for services (Cache)/vendor - Code used by Laravel/artisan [file] - Laravel Command Line Interface/paths.php [file] - Used to determine file paths
    • Laravel Application Directory/config - Application configuration files/controllers - The application "Logic"/language - Localisation files/libraries - For "drop in" single file classes/migrations - DB Schema version control files/models - Classes to interact with a database/tasks - add custom tasks to the artisan CLI/tests - Unit Testing/views - HTML Templates
    • Laravel Application Directory (cont.)/bundles.php [file] - Manages active bundles/routes.php [file] - Application Routing Mappingstart.php [file] - Start up Routines
    • Using Controllersclass Account_Controller extends Base_Controller{ public function action_index() { echo "This is the profile page."; } public function action_login() { echo "This is the login form."; } public function action_logout() { echo "This is the logout action."; }}
    • Routes with ClosuresRoute::get(/, function(){ return View::make(home.index);});Here we are responding to requests to the rootof the web app, that use the HTTP verb GETwith a Closure that simply returns a View object
    • Passing Parameters to ClosuresTo pass parameters to your Closures, simply add the usual view placeholdersto the URI, and define parameters in your Closure, they will be matched in theorder from left to right,Route::get(user/(:any)/task/(:num), function($username, $task_number){ // $username will be replaced by the value of (:any) // $task_number will be replaced by the integer in place of (:num) $data = array( username => $username, task => $task_number ); return View::make(tasks.for_user, $data);});
    • More Information● http://daylerees.com/category/laravel- tutorials● http://laravel.com/docs/● http://forums.laravel.io/● #laravel on Freenode (IRC)● https://leanpub.com/codehappyMajor Credit to Dayle Rees and his CodeHappy book. Much of the content here wasfrom his tutorials. Support him by buying hisbook: https://leanpub.com/codehappy