SlideShare uma empresa Scribd logo
1 de 77
Baixar para ler offline
LARAVEL 101
Commit University
IONUT TANASA
LARAVEL
A free, open source, MVC web-application framework
2011 (v1.0) — current (v5.0.26)
Package-based dependency management
 laravel.com
GETTING STARTED
PREREQUISITES
PHP 5.4.x
Mcrypt extension
JSON extension
Composer
and install it globally!




 getcomposer.org
YOUR FIRST PROJECT
STARTING A NEW PROJECT
composer global require "laravel/installer=~1.1"
laravel new blog
composer create-project laravel/laravel my-project --prefer-dist
git clone git@github.com:laravel/laravel.git my-project
cd my-project
composer install
curl -L -O https://github.com/laravel/laravel/archive/master.zip
unzip master.zip
mv laravel-master my-project
cd my-project
composer install
GIT IT UNDER CONTROL I see what you did.
PROJECT STRUCTURE
PROJECT FOLDERS
app < your stuff
bootstrap < startup stuff
public < static stuff: img, js, css, etc.
composer.json < other people's stuff you want
vendor < other people's stuff





APPLICATION FOLDERS
app
commands
config
controllers
database
lang
models
start
storage
tests
views
filters.php
routes.php













ARTISAN
ARTISAN
Command line tool to make working with Laravel easier.
php artisan
BUILT-IN SERVER
php artisan serve --port 8000
ROUTING
BASIC ROUTING
Route::get('/', function() {
return 'Hello World!';
});
 app/routes.php
ROUTE PARAMETERS
// pass parameters via URI
Route::get('/hello/{name}', function($name)
{
return 'Hello, ' . $name;
});
 app/routes.php
// escape output for safety
Route::get('/hello/{name}', function($name)
{
return 'Hello, ' . e($name);
});
 app/routes.php
// filter the URI data
Route::get('/hello/{name}', function($name)
{
return 'Hello, ' . e($name);
})->where('name','[A-za-z]+');
 app/routes.php
// make the param optional
Route::get('/hello/{name?}', function($name='stranger')
{
return 'Hello, ' . e($name);
})->where('name','[A-za-z]+');
 app/routes.php
LISTING ROUTES
php artisan routes
CONTROLLERS
CONTROLLER ROUTING
Route::get('hello/{name?}', 'HelloController@showWelcome');
 app/routes.php
class HelloController extends BaseController {
public function showWelcome($name='stranger')
{
return 'Hello, '. e($name) . '!';
}
}
 app/controllers/HelloController.php
RESTFUL CONTROLLERS
Route::controller('users', 'UsersController');
 app/routes.php
class UsersController extends BaseController {
public function getIndex() {
// GET http://domain.com/users
}
public function postProfile() {
// POST http://domain.com/users/profile
}
}
 app/controllers/UsersController.php
RESOURCE CONTROLLERS
php artisan controller:make PostsController
Route::resource('posts', 'PostsController');
 app/routes.php
class PostsController extends BaseController {
public function index() {}
public function create() {}
public function store() {}
public function show($id) {}
public function edit($id) {}
public function update($id) {}
public function destroy($id) {}
}
 app/controllers/PostsController.php
php artisan routes
VIEWS
PASSING DATA TO VIEWS
class HelloController extends BaseController {
public function showWelcome($name='stranger')
{
return View::make('hello', array('name'=>$name) );
}
}
 app/controller/HelloController.php
class HelloController extends BaseController {
public function showWelcome($name='stranger')
{
return View::make('hello', compact('name') );
}
}
 app/controller/HelloController.php
<html>
<body>
<p>Hello, <?php echo e($name); ?>!</p>
</body>
</html>
 app/views/hello.php
<html>
<body>
<p>Hello, {{{ $name }}}!</p>
</body>
</html>
 app/views/hello.blade.php
BLADE TEMPLATING
OUTPUTTING DATA
<html>
<body>
// echo and escape output
Hello {{ $name }}! Hello {{{ $html }}}!
</body>
</html>
 app/views/VIEWNAME.blade.php
IF STATEMENTS
@if( $name=='Bob' )
Good to see you, Bob!
@elseif( $name=='Mary' )
Howya doing, Mary!
@else
Hey, where did Bob go?
@endif
@unless( $signed_in )
You are not signed in.
@endunless
 app/views/VIEWNAME.blade.php
LOOPS
@for ($i = 0; $i < 10; $i++)
The current value is {{ $i }}
@endfor
@foreach ($users as $user)
<p>This is user {{ $user->id }}</p>
@endforeach
@while (true)
<p>Make it stop!</p>
@endwhile
 app/views/VIEWNAME.blade.php
LAYOUTS
<html>
<body>
@include('header') {{-- app/views/header.blade.php --}}
@section('sidebar')
This is the master sidebar.
@show
<div class="container">
@yield('content', 'Default content')
</div>
</body>
</html>
 app/views/layouts/master.blade.php
@extends('layouts.master')
@section('sidebar')
@parent
<p>This is appended to the master sidebar.</p>
@stop
@section('content')
 app/views/VIEWNAME.blade.php
DATABASE
SUPPORTED DATABASES
Out-of-the-box support for:
MySQL
Postgres
SQLite
SQL Server




CONFIGURATION
return array(
'default' => 'mysql',
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'my-project',
'username' => 'db_user',
'password' => 's3creT_pa5sw0rD'
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
…
 app/config/database.php
return array(
'default' => 'mysql',
'connections' => array(
'mysql' => array(
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'my-project',
'username' => $_ENV['MYSQL_USER'],
'password' => $_ENV['MYSQL_PASS'],
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
),
…
 app/config/database.php
SECRET ENVIRONMENT
VARIABLES
return array(
'MYSQL_USER' => 'dbuser',
'MYSQL_PASS' => 's3creT_pa5sw0rD',
);
 .env.php
MIGRATIONS
PREPARING
php artisan migrate:install
php artisan migrate:make create_posts_table --create="posts"
MIGRATION FILE
use IlluminateDatabaseSchemaBlueprint;
use IlluminateDatabaseMigrationsMigration;
class CreatePostsTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
//
}
/**
* Reverse the migrations.
*
 app/database/migrations/###_create_posts_table.php
SCHEMA BUILDING
public function up()
{
Schema::create('posts', function(Blueprint $table) {
$table->increments('id');
$table->string('title', 50);
$table->text('text')->nullable();
$table->boolean('active')->default(true);
$table->timestamps(); // created_at and updated_at
});
}
public function down()
{
Schema::drop('posts');
}
RUN MIGRATIONS
php artisan migrate
OOOPS!
php artisan migrate:rollback
MODELS
ELOQUENT
class Post extends Eloquent {}
 app/models/Post.php
CREATE A NEW MODEL
$post = Post::create(
array(
'title' => 'My First Post',
'text' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit
'active' => true,
)
);
RETRIEVING
$post = Post::find(1);
$post = Post::findOrFail(1);
$posts = Post::where('id','>',3)->get();
$post = Post::where('title','LIKE','laravel')->first();
$posts = Post::all();
USING
$post = Post::find(1);
echo $post->title;
echo $post->created_at; // uses Carbon package for date handling
$posts = Post::all();
foreach( $posts as $post )
{
echo $post->title;
}
DELETING
$post = Post::find(1);
$post->delete();
Post::destroy(1);
Post::destroy(1,2,3);
$lastWeek = Carbon::now()->subWeek();
Post::where('created_at','<', $lastWeek)->delete();
ACCESSORS & MUTATORS
ACCESSORS
class Post extends Eloquent {
public function getTitleAttribute($value)
{
return ucwords($value);
}
}
$post = Post::create(array(
'title' => 'my first post'
));
echo $post->title; // "My First Post"
MUTATORS
class Post extends Eloquent {
public function setTextAttribute($value)
{
$value = trim($value);
$this->attributes['text'] = $value;
// not limited to modifying the one attribute
$this->attributes['excerpt'] = substr($value,0,97) . '...'
}
}
RELATIONSHIPS
ONE-TO-ONE
class Comment extends Eloquent {
// comments table has an `author_id` field
public function author()
{
return $this->hasOne('Author');
}
}
$author = Comment::find(1)->author;
INVERSE
class Author extends Eloquent {
// authors table needs a `post_id` column
public function comment()
{
return $this->belongsTo('Comment');
}
}
$title = Author::find(1)->comment->title;
ONE-TO-MANY
class Book extends Eloquent {
// books table has `author_id` column
public function author()
{
return $this->belongsTo('Author');
}
}
class Author extends Eloquent {
public function books()
{
return $this->hasMany('Book');
}
$my_books = Author::where('firstname','=','Ionut')->books;
MANY-TO-MANY
class Book extends Eloquent {
public function tags()
{
return $this->belongsToMany('Tag');
}
}
class Tag extends Eloquent {
public function books()
{
return $this->belongsToMany('Book');
}
}
PIVOT TABLE
Schema::create('book_tag', function(Blueprint $table) {
$table->increments('id');
$table->integer('book_id')->unsigned()->index();
$table->integer('tag_id')->unsigned()->index();
});
EAGER LOADING
Book::with('author')->get();
Book::with('author','tags')->get();
Tag::with('books.author')->get();
FORM HANDING
BUILDING FORMS
{{ Form::open() }}
{{ Form::label('title') }}
{{ Form::text('title', 'default', array('class'=>'form-control') }}
{{ Form::label('text', 'Enter the full text:') }}
{{ Form::textarea('text', 'default', array('placeholder'=>'Enter the text
{{ Form::email('email') }}
{{ Form::checkbox('is_active', 1, null, array('tabindex'=>4) }}
{{ Form::label('is_active', 'Yes') }}
{{ Form::submit('Send it!')}}
{{ Form::close() }}
HANDLING INPUT
$input = Input::get('field','default');
$input = Input::only('firstname','lastname');
$input = Input::except('credit_card');
$input = Input::get('choices.0.name');
$input = Input::all();
$input = Input::file('upload_field');
FORM MODEL BINDING
$book = Book::findOrFail($id);
return View::make('books.edit', compact('book'));
{{ Form::model($book, array('route'=>array('books.update', $book
{{ Form::text('title')}}
{{ Form::textarea('description')}}
…
{{ Form::close() }}
VALIDATION
VALIDATION RULES
$data = array(
'title' => 'My First Post',
'text' => 'Lorem hipster YOLO sic amet, semiotics banh mi flexitarian.
));
$rules = array(
'title' => 'required|min:5',
'description' => 'required|max:100'
);
VALIDATION
$validator = Validator::make( $data, $rules );
if ( $validator->fails() ) // ->passes()
{
$messages = $validator->messages();
…
}
if ( $messages->has('email') )
{
echo $messages->first('email', '<p>:message</p>');
}
$messages->get('field');
$messages->all();
VALIDATION RULES
$rules = array(
'firstname' => 'required',
'lastname' => 'alpha',
'email' => 'email',
'age' => 'integer|between:18,65',
'agree' => array('required','accepted'),
'website' => 'url',
'password' => 'confirmed', // implies matching 'password
'company_id' => 'exists:companies,id',
'gender' => 'in:male,female',
'photo' => 'mimes:jpeg,png|max:100', // kilobytes
'postalcode' => 'regex:^[A-Z][0-9][A-Z] ?[0-9][A-Z][0-9]$'
);
LOGGING
LOGGING
Built on top of  Monolog
Log::info('This is some useful information.');
Log::info('Information with context', array('context' => 'Other helpful i
Log::warning('Something could be going wrong.');
Log::error('OMGWTFBBQ!');
 app/storage/logs/laravel.log
QUERY LOGGING
$queries = DB::getQueryLog();
DB::connection()->disableQueryLog();
CACHING
CACHE CONFIGURATION
 app/config/cache.php
Drivers:
file
database
apc
memcached
redis
array








CACHE USAGE
Cache::put('key', 'value', $minutes);
$expiresAt = Carbon::now()->addHours(10);
Cache::put('key', 'value', $expiresAt);
if (Cache::has('key')) { … }
$value = Cache::get('key');
$value = Cache::get('key', 'default');
$value = Cache::get('key', function() { return 'default'; });
$value = Cache::forever('key', 'value');
Cache::forget('key');
ADVANCED CACHE USAGE
$books = Cache::remember('all-books', 10, function()
{
return Book::with('author')
->orderBy('title')
->get();
});
MAIL
MAIL CONFIGURATION
Built on top of
 app/config/mail.php
Drivers:
smtp
mail
sendmail
  SwiftMailer





MAIL USAGE
Mail::send('emails.view', $data, function($message)
{
$message->to('ionut@example.com', 'Ionut Tanasa')
->subject('Welcome!');
});
Mail::send( array('emails.view.html', 'emails.view.text'), $data
{
$message->to('ionut@example.com', 'Ionut Tanasa')
->subject('Welcome!');
});
Mail::send( array('emails.view.html', 'emails.view.text'), $data
{
$message->to('ionut@example.com', 'Ionut Tanasa')
->subject('Welcome!')
->cc('bar@example.com')
->bcc('snoop@nsa.gov');
});
Mail::send( array('emails.view.html', 'emails.view.text'), $data
{
$message->to('ionut@example.com', 'Ionut Tanasa')
->subject('Welcome!')
->cc('bar@example.com')
->bcc('snoop@nsa.gov');
$message->attach($pathToFile);
});
Mail::send( array('emails.view.html', 'emails.view.text'), $data
{
$message->to('ionut@example.com', 'Ionut Tanasa')
->subject('Welcome!')
->cc('bar@example.com')
->bcc('snoop@nsa.gov');
$message->attach($pathToFile, array('as' => $display, 'mime' =>
});
INLINE DATA
<body>
Here is an image <img src="{{ $message->embed($pathToFile) }}"
</body>
<body>
Here is raw image data <img src="{{ $message->embedData($data, $name) }
</body>
QUEUEING MAIL
Mail::queue('emails.view', $data, function($message)
{
$message->to('ionut@example.com', 'Ionut Tanasa')
->subject('Welcome!');
});
Mail::later($seconds, 'emails.view', $data, function($message)
{
$message->to('ionut@example.com', 'Ionut Tanasa')
->subject('Welcome!');
});
AUTHENTICATION
EVENTS
LOCALIZATION
QUEUES
PACKAGES
FURTHER READING
 laravel.com/docs
 laravel.com/api
 github.com/laravel
 laravel.io
 laracasts.com
 github.com/cviebrock
That’s All Folks!

Mais conteúdo relacionado

Mais procurados

Laravel - The PHP Framework for Web Artisans
Laravel - The PHP Framework for Web ArtisansLaravel - The PHP Framework for Web Artisans
Laravel - The PHP Framework for Web ArtisansWindzoon Technologies
 
Projects In Laravel : Learn Laravel Building 10 Projects
Projects In Laravel : Learn Laravel Building 10 ProjectsProjects In Laravel : Learn Laravel Building 10 Projects
Projects In Laravel : Learn Laravel Building 10 ProjectsSam Dias
 
Web application development with laravel php framework version 4
Web application development with laravel php framework version 4Web application development with laravel php framework version 4
Web application development with laravel php framework version 4Untung D Saptoto
 
Laravel Routing and Query Building
Laravel   Routing and Query BuildingLaravel   Routing and Query Building
Laravel Routing and Query BuildingMindfire Solutions
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShellSalaudeen Rajack
 
Code igniter - A brief introduction
Code igniter - A brief introductionCode igniter - A brief introduction
Code igniter - A brief introductionCommit University
 
Introduction to laravel framework
Introduction to laravel frameworkIntroduction to laravel framework
Introduction to laravel frameworkAhmad Fatoni
 
Spring Framework - MVC
Spring Framework - MVCSpring Framework - MVC
Spring Framework - MVCDzmitry Naskou
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectJadson Santos
 
What-is-Laravel-23-August-2017.pptx
What-is-Laravel-23-August-2017.pptxWhat-is-Laravel-23-August-2017.pptx
What-is-Laravel-23-August-2017.pptxAbhijeetKumar456867
 
An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.jsPagepro
 

Mais procurados (20)

Laravel overview
Laravel overviewLaravel overview
Laravel overview
 
Laravel - The PHP Framework for Web Artisans
Laravel - The PHP Framework for Web ArtisansLaravel - The PHP Framework for Web Artisans
Laravel - The PHP Framework for Web Artisans
 
Projects In Laravel : Learn Laravel Building 10 Projects
Projects In Laravel : Learn Laravel Building 10 ProjectsProjects In Laravel : Learn Laravel Building 10 Projects
Projects In Laravel : Learn Laravel Building 10 Projects
 
Laravel ppt
Laravel pptLaravel ppt
Laravel ppt
 
Web application development with laravel php framework version 4
Web application development with laravel php framework version 4Web application development with laravel php framework version 4
Web application development with laravel php framework version 4
 
Laravel Eloquent ORM
Laravel Eloquent ORMLaravel Eloquent ORM
Laravel Eloquent ORM
 
Laravel Routing and Query Building
Laravel   Routing and Query BuildingLaravel   Routing and Query Building
Laravel Routing and Query Building
 
laravel.pptx
laravel.pptxlaravel.pptx
laravel.pptx
 
01 Php Introduction
01 Php Introduction01 Php Introduction
01 Php Introduction
 
Spring Boot Tutorial
Spring Boot TutorialSpring Boot Tutorial
Spring Boot Tutorial
 
Docker swarm
Docker swarmDocker swarm
Docker swarm
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
 
Code igniter - A brief introduction
Code igniter - A brief introductionCode igniter - A brief introduction
Code igniter - A brief introduction
 
Introduction to laravel framework
Introduction to laravel frameworkIntroduction to laravel framework
Introduction to laravel framework
 
Spring Framework - MVC
Spring Framework - MVCSpring Framework - MVC
Spring Framework - MVC
 
Model View Controller (MVC)
Model View Controller (MVC)Model View Controller (MVC)
Model View Controller (MVC)
 
PHP MVC
PHP MVCPHP MVC
PHP MVC
 
Introduction to angular with a simple but complete project
Introduction to angular with a simple but complete projectIntroduction to angular with a simple but complete project
Introduction to angular with a simple but complete project
 
What-is-Laravel-23-August-2017.pptx
What-is-Laravel-23-August-2017.pptxWhat-is-Laravel-23-August-2017.pptx
What-is-Laravel-23-August-2017.pptx
 
An introduction to Vue.js
An introduction to Vue.jsAn introduction to Vue.js
An introduction to Vue.js
 

Destaque

How to learn Laravel5 application from Authentication
How to learn Laravel5 application from AuthenticationHow to learn Laravel5 application from Authentication
How to learn Laravel5 application from AuthenticationMasashi Shinbara
 
MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 Joe Ferguson
 
Software Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill SparksSoftware Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill SparksPhill Sparks
 

Destaque (8)

Workshop Laravel 5.2
Workshop Laravel 5.2Workshop Laravel 5.2
Workshop Laravel 5.2
 
How to learn Laravel5 application from Authentication
How to learn Laravel5 application from AuthenticationHow to learn Laravel5 application from Authentication
How to learn Laravel5 application from Authentication
 
MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5 MidwestPHP 2016 - Adventures in Laravel 5
MidwestPHP 2016 - Adventures in Laravel 5
 
Laravel 5
Laravel 5Laravel 5
Laravel 5
 
(Have a) rest with Laravel
(Have a) rest with Laravel(Have a) rest with Laravel
(Have a) rest with Laravel
 
Laravel 5.4
Laravel 5.4 Laravel 5.4
Laravel 5.4
 
Software Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill SparksSoftware Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill Sparks
 
reveal.js 3.0.0
reveal.js 3.0.0reveal.js 3.0.0
reveal.js 3.0.0
 

Semelhante a Laravel 101

Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For BeginnersJonathan Wage
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐいHisateru Tanaka
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the FinishYehuda Katz
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5Darren Craig
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)arcware
 
Codeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationCodeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationAbdul Malik Ikhsan
 
How to develop modern web application framework
How to develop modern web application frameworkHow to develop modern web application framework
How to develop modern web application frameworktechmemo
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overviewYehuda Katz
 
Frameworks da nova Era PHP FuelPHP
Frameworks da nova Era PHP FuelPHPFrameworks da nova Era PHP FuelPHP
Frameworks da nova Era PHP FuelPHPDan Jesus
 
Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18Lar21
 
Durian: a PHP 5.5 microframework with generator-style middleware
Durian: a PHP 5.5 microframework with generator-style middlewareDurian: a PHP 5.5 microframework with generator-style middleware
Durian: a PHP 5.5 microframework with generator-style middlewareKuan Yen Heng
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPresswpnepal
 
Aura Project for PHP
Aura Project for PHPAura Project for PHP
Aura Project for PHPHari K T
 
Ruby/Rails
Ruby/RailsRuby/Rails
Ruby/Railsrstankov
 
Teaming up WordPress API with Backbone.js in Titanium
Teaming up WordPress API with Backbone.js in TitaniumTeaming up WordPress API with Backbone.js in Titanium
Teaming up WordPress API with Backbone.js in TitaniumJeroen van Dijk
 

Semelhante a Laravel 101 (20)

Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
 
Doctrine and NoSQL
Doctrine and NoSQLDoctrine and NoSQL
Doctrine and NoSQL
 
Doctrine For Beginners
Doctrine For BeginnersDoctrine For Beginners
Doctrine For Beginners
 
関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい関西PHP勉強会 php5.4つまみぐい
関西PHP勉強会 php5.4つまみぐい
 
Rails 3: Dashing to the Finish
Rails 3: Dashing to the FinishRails 3: Dashing to the Finish
Rails 3: Dashing to the Finish
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5
 
Doctrine for NoSQL
Doctrine for NoSQLDoctrine for NoSQL
Doctrine for NoSQL
 
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
10 Things Every Plugin Developer Should Know (WordCamp Atlanta 2013)
 
Codeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationCodeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept Implementation
 
How to develop modern web application framework
How to develop modern web application frameworkHow to develop modern web application framework
How to develop modern web application framework
 
Rails 3 overview
Rails 3 overviewRails 3 overview
Rails 3 overview
 
Frameworks da nova Era PHP FuelPHP
Frameworks da nova Era PHP FuelPHPFrameworks da nova Era PHP FuelPHP
Frameworks da nova Era PHP FuelPHP
 
Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18
 
Durian: a PHP 5.5 microframework with generator-style middleware
Durian: a PHP 5.5 microframework with generator-style middlewareDurian: a PHP 5.5 microframework with generator-style middleware
Durian: a PHP 5.5 microframework with generator-style middleware
 
Avinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPressAvinash Kundaliya: Javascript and WordPress
Avinash Kundaliya: Javascript and WordPress
 
Aura Project for PHP
Aura Project for PHPAura Project for PHP
Aura Project for PHP
 
Play!ng with scala
Play!ng with scalaPlay!ng with scala
Play!ng with scala
 
Ruby/Rails
Ruby/RailsRuby/Rails
Ruby/Rails
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
Teaming up WordPress API with Backbone.js in Titanium
Teaming up WordPress API with Backbone.js in TitaniumTeaming up WordPress API with Backbone.js in Titanium
Teaming up WordPress API with Backbone.js in Titanium
 

Mais de Commit University

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdfBreaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdfCommit University
 
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdfAccelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdfCommit University
 
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...Commit University
 
Commit - Qwik il framework che ti stupirà.pptx
Commit - Qwik il framework che ti stupirà.pptxCommit - Qwik il framework che ti stupirà.pptx
Commit - Qwik il framework che ti stupirà.pptxCommit University
 
Sviluppare da zero una Angular Web App per la PA
Sviluppare da zero una Angular Web App per la PASviluppare da zero una Angular Web App per la PA
Sviluppare da zero una Angular Web App per la PACommit University
 
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...Commit University
 
Prisma the ORM that node was waiting for
Prisma the ORM that node was waiting forPrisma the ORM that node was waiting for
Prisma the ORM that node was waiting forCommit University
 
Decision-making for Software Development Teams - Commit University
Decision-making for Software Development Teams - Commit UniversityDecision-making for Software Development Teams - Commit University
Decision-making for Software Development Teams - Commit UniversityCommit University
 
Component Design Pattern nei Game Engine.pdf
Component Design Pattern nei Game Engine.pdfComponent Design Pattern nei Game Engine.pdf
Component Design Pattern nei Game Engine.pdfCommit University
 
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...Commit University
 
Prototipazione Low-Code con AWS Step Functions
Prototipazione Low-Code con AWS Step FunctionsPrototipazione Low-Code con AWS Step Functions
Prototipazione Low-Code con AWS Step FunctionsCommit University
 
KMM survival guide: how to tackle struggles between Kotlin and Swift
KMM survival guide: how to tackle struggles between Kotlin and SwiftKMM survival guide: how to tackle struggles between Kotlin and Swift
KMM survival guide: how to tackle struggles between Kotlin and SwiftCommit University
 
Da Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazioneDa Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazioneCommit University
 
Orchestrare Micro-frontend con micro-lc
Orchestrare Micro-frontend con micro-lcOrchestrare Micro-frontend con micro-lc
Orchestrare Micro-frontend con micro-lcCommit University
 
Fastify has defeated Lagacy-Code
Fastify has defeated Lagacy-CodeFastify has defeated Lagacy-Code
Fastify has defeated Lagacy-CodeCommit University
 

Mais de Commit University (20)

Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdfBreaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
Breaking REST Chains_ A Fastify & Mercurius Pathway to GraphQL Glory.pdf
 
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdfAccelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
Accelerating API Development: A Pit Stop with Gin-Gonic in Golang-Slide.pdf
 
Slide-10years.pdf
Slide-10years.pdfSlide-10years.pdf
Slide-10years.pdf
 
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
Collaborazione, Decisionalità e Gestione della Complessità nel Tempo: cosa ...
 
Vue.js slots.pdf
Vue.js slots.pdfVue.js slots.pdf
Vue.js slots.pdf
 
Commit - Qwik il framework che ti stupirà.pptx
Commit - Qwik il framework che ti stupirà.pptxCommit - Qwik il framework che ti stupirà.pptx
Commit - Qwik il framework che ti stupirà.pptx
 
Sviluppare da zero una Angular Web App per la PA
Sviluppare da zero una Angular Web App per la PASviluppare da zero una Angular Web App per la PA
Sviluppare da zero una Angular Web App per la PA
 
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
Backstage l'Internal Developer Portal Open Source per una migliore Developer ...
 
Prisma the ORM that node was waiting for
Prisma the ORM that node was waiting forPrisma the ORM that node was waiting for
Prisma the ORM that node was waiting for
 
Decision-making for Software Development Teams - Commit University
Decision-making for Software Development Teams - Commit UniversityDecision-making for Software Development Teams - Commit University
Decision-making for Software Development Teams - Commit University
 
Component Design Pattern nei Game Engine.pdf
Component Design Pattern nei Game Engine.pdfComponent Design Pattern nei Game Engine.pdf
Component Design Pattern nei Game Engine.pdf
 
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
Un viaggio alla scoperta dei Language Models e dell’intelligenza artificiale ...
 
Prototipazione Low-Code con AWS Step Functions
Prototipazione Low-Code con AWS Step FunctionsPrototipazione Low-Code con AWS Step Functions
Prototipazione Low-Code con AWS Step Functions
 
KMM survival guide: how to tackle struggles between Kotlin and Swift
KMM survival guide: how to tackle struggles between Kotlin and SwiftKMM survival guide: how to tackle struggles between Kotlin and Swift
KMM survival guide: how to tackle struggles between Kotlin and Swift
 
Da Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazioneDa Vuex a Pinia: come fare la migrazione
Da Vuex a Pinia: come fare la migrazione
 
Orchestrare Micro-frontend con micro-lc
Orchestrare Micro-frontend con micro-lcOrchestrare Micro-frontend con micro-lc
Orchestrare Micro-frontend con micro-lc
 
Fastify has defeated Lagacy-Code
Fastify has defeated Lagacy-CodeFastify has defeated Lagacy-Code
Fastify has defeated Lagacy-Code
 
SwiftUI vs UIKit
SwiftUI vs UIKitSwiftUI vs UIKit
SwiftUI vs UIKit
 

Último

Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbuapidays
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 

Último (20)

Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 

Laravel 101

  • 3. LARAVEL A free, open source, MVC web-application framework 2011 (v1.0) — current (v5.0.26) Package-based dependency management  laravel.com
  • 5. PREREQUISITES PHP 5.4.x Mcrypt extension JSON extension Composer and install it globally!      getcomposer.org
  • 7. STARTING A NEW PROJECT composer global require "laravel/installer=~1.1" laravel new blog composer create-project laravel/laravel my-project --prefer-dist git clone git@github.com:laravel/laravel.git my-project cd my-project composer install curl -L -O https://github.com/laravel/laravel/archive/master.zip unzip master.zip mv laravel-master my-project cd my-project composer install
  • 8. GIT IT UNDER CONTROL I see what you did.
  • 10. PROJECT FOLDERS app < your stuff bootstrap < startup stuff public < static stuff: img, js, css, etc. composer.json < other people's stuff you want vendor < other people's stuff     
  • 13. ARTISAN Command line tool to make working with Laravel easier. php artisan
  • 14. BUILT-IN SERVER php artisan serve --port 8000
  • 16. BASIC ROUTING Route::get('/', function() { return 'Hello World!'; });  app/routes.php
  • 17. ROUTE PARAMETERS // pass parameters via URI Route::get('/hello/{name}', function($name) { return 'Hello, ' . $name; });  app/routes.php // escape output for safety Route::get('/hello/{name}', function($name) { return 'Hello, ' . e($name); });  app/routes.php // filter the URI data Route::get('/hello/{name}', function($name) { return 'Hello, ' . e($name); })->where('name','[A-za-z]+');  app/routes.php // make the param optional Route::get('/hello/{name?}', function($name='stranger') { return 'Hello, ' . e($name); })->where('name','[A-za-z]+');  app/routes.php
  • 20. CONTROLLER ROUTING Route::get('hello/{name?}', 'HelloController@showWelcome');  app/routes.php class HelloController extends BaseController { public function showWelcome($name='stranger') { return 'Hello, '. e($name) . '!'; } }  app/controllers/HelloController.php
  • 21. RESTFUL CONTROLLERS Route::controller('users', 'UsersController');  app/routes.php class UsersController extends BaseController { public function getIndex() { // GET http://domain.com/users } public function postProfile() { // POST http://domain.com/users/profile } }  app/controllers/UsersController.php
  • 22. RESOURCE CONTROLLERS php artisan controller:make PostsController Route::resource('posts', 'PostsController');  app/routes.php class PostsController extends BaseController { public function index() {} public function create() {} public function store() {} public function show($id) {} public function edit($id) {} public function update($id) {} public function destroy($id) {} }  app/controllers/PostsController.php php artisan routes
  • 23. VIEWS
  • 24. PASSING DATA TO VIEWS class HelloController extends BaseController { public function showWelcome($name='stranger') { return View::make('hello', array('name'=>$name) ); } }  app/controller/HelloController.php class HelloController extends BaseController { public function showWelcome($name='stranger') { return View::make('hello', compact('name') ); } }  app/controller/HelloController.php <html> <body> <p>Hello, <?php echo e($name); ?>!</p> </body> </html>  app/views/hello.php <html> <body> <p>Hello, {{{ $name }}}!</p> </body> </html>  app/views/hello.blade.php
  • 26. OUTPUTTING DATA <html> <body> // echo and escape output Hello {{ $name }}! Hello {{{ $html }}}! </body> </html>  app/views/VIEWNAME.blade.php
  • 27. IF STATEMENTS @if( $name=='Bob' ) Good to see you, Bob! @elseif( $name=='Mary' ) Howya doing, Mary! @else Hey, where did Bob go? @endif @unless( $signed_in ) You are not signed in. @endunless  app/views/VIEWNAME.blade.php
  • 28. LOOPS @for ($i = 0; $i < 10; $i++) The current value is {{ $i }} @endfor @foreach ($users as $user) <p>This is user {{ $user->id }}</p> @endforeach @while (true) <p>Make it stop!</p> @endwhile  app/views/VIEWNAME.blade.php
  • 29. LAYOUTS <html> <body> @include('header') {{-- app/views/header.blade.php --}} @section('sidebar') This is the master sidebar. @show <div class="container"> @yield('content', 'Default content') </div> </body> </html>  app/views/layouts/master.blade.php @extends('layouts.master') @section('sidebar') @parent <p>This is appended to the master sidebar.</p> @stop @section('content')  app/views/VIEWNAME.blade.php
  • 31. SUPPORTED DATABASES Out-of-the-box support for: MySQL Postgres SQLite SQL Server    
  • 32. CONFIGURATION return array( 'default' => 'mysql', 'connections' => array( 'mysql' => array( 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'my-project', 'username' => 'db_user', 'password' => 's3creT_pa5sw0rD' 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ), …  app/config/database.php return array( 'default' => 'mysql', 'connections' => array( 'mysql' => array( 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'my-project', 'username' => $_ENV['MYSQL_USER'], 'password' => $_ENV['MYSQL_PASS'], 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ), …  app/config/database.php
  • 33. SECRET ENVIRONMENT VARIABLES return array( 'MYSQL_USER' => 'dbuser', 'MYSQL_PASS' => 's3creT_pa5sw0rD', );  .env.php
  • 35. PREPARING php artisan migrate:install php artisan migrate:make create_posts_table --create="posts"
  • 36. MIGRATION FILE use IlluminateDatabaseSchemaBlueprint; use IlluminateDatabaseMigrationsMigration; class CreatePostsTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { // } /** * Reverse the migrations. *  app/database/migrations/###_create_posts_table.php
  • 37. SCHEMA BUILDING public function up() { Schema::create('posts', function(Blueprint $table) { $table->increments('id'); $table->string('title', 50); $table->text('text')->nullable(); $table->boolean('active')->default(true); $table->timestamps(); // created_at and updated_at }); } public function down() { Schema::drop('posts'); }
  • 38. RUN MIGRATIONS php artisan migrate OOOPS! php artisan migrate:rollback
  • 40. ELOQUENT class Post extends Eloquent {}  app/models/Post.php
  • 41. CREATE A NEW MODEL $post = Post::create( array( 'title' => 'My First Post', 'text' => 'Lorem ipsum dolor sit amet, consectetur adipisicing elit 'active' => true, ) );
  • 42. RETRIEVING $post = Post::find(1); $post = Post::findOrFail(1); $posts = Post::where('id','>',3)->get(); $post = Post::where('title','LIKE','laravel')->first(); $posts = Post::all();
  • 43. USING $post = Post::find(1); echo $post->title; echo $post->created_at; // uses Carbon package for date handling $posts = Post::all(); foreach( $posts as $post ) { echo $post->title; }
  • 44. DELETING $post = Post::find(1); $post->delete(); Post::destroy(1); Post::destroy(1,2,3); $lastWeek = Carbon::now()->subWeek(); Post::where('created_at','<', $lastWeek)->delete();
  • 46. ACCESSORS class Post extends Eloquent { public function getTitleAttribute($value) { return ucwords($value); } } $post = Post::create(array( 'title' => 'my first post' )); echo $post->title; // "My First Post"
  • 47. MUTATORS class Post extends Eloquent { public function setTextAttribute($value) { $value = trim($value); $this->attributes['text'] = $value; // not limited to modifying the one attribute $this->attributes['excerpt'] = substr($value,0,97) . '...' } }
  • 49. ONE-TO-ONE class Comment extends Eloquent { // comments table has an `author_id` field public function author() { return $this->hasOne('Author'); } } $author = Comment::find(1)->author;
  • 50. INVERSE class Author extends Eloquent { // authors table needs a `post_id` column public function comment() { return $this->belongsTo('Comment'); } } $title = Author::find(1)->comment->title;
  • 51. ONE-TO-MANY class Book extends Eloquent { // books table has `author_id` column public function author() { return $this->belongsTo('Author'); } } class Author extends Eloquent { public function books() { return $this->hasMany('Book'); } $my_books = Author::where('firstname','=','Ionut')->books;
  • 52. MANY-TO-MANY class Book extends Eloquent { public function tags() { return $this->belongsToMany('Tag'); } } class Tag extends Eloquent { public function books() { return $this->belongsToMany('Book'); } }
  • 53. PIVOT TABLE Schema::create('book_tag', function(Blueprint $table) { $table->increments('id'); $table->integer('book_id')->unsigned()->index(); $table->integer('tag_id')->unsigned()->index(); });
  • 56. BUILDING FORMS {{ Form::open() }} {{ Form::label('title') }} {{ Form::text('title', 'default', array('class'=>'form-control') }} {{ Form::label('text', 'Enter the full text:') }} {{ Form::textarea('text', 'default', array('placeholder'=>'Enter the text {{ Form::email('email') }} {{ Form::checkbox('is_active', 1, null, array('tabindex'=>4) }} {{ Form::label('is_active', 'Yes') }} {{ Form::submit('Send it!')}} {{ Form::close() }}
  • 57. HANDLING INPUT $input = Input::get('field','default'); $input = Input::only('firstname','lastname'); $input = Input::except('credit_card'); $input = Input::get('choices.0.name'); $input = Input::all(); $input = Input::file('upload_field');
  • 58. FORM MODEL BINDING $book = Book::findOrFail($id); return View::make('books.edit', compact('book')); {{ Form::model($book, array('route'=>array('books.update', $book {{ Form::text('title')}} {{ Form::textarea('description')}} … {{ Form::close() }}
  • 60. VALIDATION RULES $data = array( 'title' => 'My First Post', 'text' => 'Lorem hipster YOLO sic amet, semiotics banh mi flexitarian. )); $rules = array( 'title' => 'required|min:5', 'description' => 'required|max:100' );
  • 61. VALIDATION $validator = Validator::make( $data, $rules ); if ( $validator->fails() ) // ->passes() { $messages = $validator->messages(); … } if ( $messages->has('email') ) { echo $messages->first('email', '<p>:message</p>'); } $messages->get('field'); $messages->all();
  • 62. VALIDATION RULES $rules = array( 'firstname' => 'required', 'lastname' => 'alpha', 'email' => 'email', 'age' => 'integer|between:18,65', 'agree' => array('required','accepted'), 'website' => 'url', 'password' => 'confirmed', // implies matching 'password 'company_id' => 'exists:companies,id', 'gender' => 'in:male,female', 'photo' => 'mimes:jpeg,png|max:100', // kilobytes 'postalcode' => 'regex:^[A-Z][0-9][A-Z] ?[0-9][A-Z][0-9]$' );
  • 64. LOGGING Built on top of  Monolog Log::info('This is some useful information.'); Log::info('Information with context', array('context' => 'Other helpful i Log::warning('Something could be going wrong.'); Log::error('OMGWTFBBQ!');  app/storage/logs/laravel.log
  • 65. QUERY LOGGING $queries = DB::getQueryLog(); DB::connection()->disableQueryLog();
  • 68. CACHE USAGE Cache::put('key', 'value', $minutes); $expiresAt = Carbon::now()->addHours(10); Cache::put('key', 'value', $expiresAt); if (Cache::has('key')) { … } $value = Cache::get('key'); $value = Cache::get('key', 'default'); $value = Cache::get('key', function() { return 'default'; }); $value = Cache::forever('key', 'value'); Cache::forget('key');
  • 69. ADVANCED CACHE USAGE $books = Cache::remember('all-books', 10, function() { return Book::with('author') ->orderBy('title') ->get(); });
  • 70. MAIL
  • 71. MAIL CONFIGURATION Built on top of  app/config/mail.php Drivers: smtp mail sendmail   SwiftMailer     
  • 72. MAIL USAGE Mail::send('emails.view', $data, function($message) { $message->to('ionut@example.com', 'Ionut Tanasa') ->subject('Welcome!'); }); Mail::send( array('emails.view.html', 'emails.view.text'), $data { $message->to('ionut@example.com', 'Ionut Tanasa') ->subject('Welcome!'); }); Mail::send( array('emails.view.html', 'emails.view.text'), $data { $message->to('ionut@example.com', 'Ionut Tanasa') ->subject('Welcome!') ->cc('bar@example.com') ->bcc('snoop@nsa.gov'); }); Mail::send( array('emails.view.html', 'emails.view.text'), $data { $message->to('ionut@example.com', 'Ionut Tanasa') ->subject('Welcome!') ->cc('bar@example.com') ->bcc('snoop@nsa.gov'); $message->attach($pathToFile); }); Mail::send( array('emails.view.html', 'emails.view.text'), $data { $message->to('ionut@example.com', 'Ionut Tanasa') ->subject('Welcome!') ->cc('bar@example.com') ->bcc('snoop@nsa.gov'); $message->attach($pathToFile, array('as' => $display, 'mime' => });
  • 73. INLINE DATA <body> Here is an image <img src="{{ $message->embed($pathToFile) }}" </body> <body> Here is raw image data <img src="{{ $message->embedData($data, $name) } </body>
  • 74. QUEUEING MAIL Mail::queue('emails.view', $data, function($message) { $message->to('ionut@example.com', 'Ionut Tanasa') ->subject('Welcome!'); }); Mail::later($seconds, 'emails.view', $data, function($message) { $message->to('ionut@example.com', 'Ionut Tanasa') ->subject('Welcome!'); });
  • 76. FURTHER READING  laravel.com/docs  laravel.com/api  github.com/laravel  laravel.io  laracasts.com  github.com/cviebrock