SlideShare uma empresa Scribd logo
1 de 29
Baixar para ler offline
LARAVEL 5
What is Laravel?
• PHP Framework
• Most popular on Github
• MVC Architecture
• MIT License
Why Laravel?
• Composer
• Community
• Code Construction
@bukhorimuhammad
Less Talking, 

More Coding
Requirements
• Composer
• Local server (with XAMPP, WAMP, MAMP, etc)
• PHP 5.4+
• Mcrypt, OpenSSL, Mbstring, Tokenizer & PHP
JSON extension
COMPOSER
Composer is a tool for dependency management in PHP. It allows
you to declare the dependent libraries your project needs and it will
install them in your project for you.


https://getcomposer.org
UNIX : curl -sS https://getcomposer.org/installer | php
WIN : https://getcomposer.org/Composer-Setup.exe
Installing Laravel
Composer Global :
composer create-project laravel/laravel —-
prefer-dist foldername
Composer Local :
php /path/to/composer.phar create-project
laravel/laravel --prefer-dist foldername
Fix Folder Permission
• Set storage folder to be writable (777)
• Set vendor folder to be writable (777)
@bukhorimuhammad
Laravel Concepts
Laravel Artisan
Artisan is the name of the command-line interface included with
Laravel. It provides a number of helpful commands for your use
while developing your application. It is driven by the powerful
Symfony Console component.
php artisan list : 

list all available artisan command
php artisan help [command] : 

help information for each command
http://laravel.com/docs/5.0/artisan
Laravel Routing
Routing is the process of taking a URI endpoint (that part of the
URI which comes after the base URL) and decomposing it into
parameters to determine which module, controller, and action of
that controller should receive the request.
http://laravel.com/docs/5.0/routing
Route::get('/', function()
{
return 'Hello World';
});
Route::post('foo/bar', function()
{
return 'Hello World';
});
Route::any('foo', function()
{
return 'Hello World';
});
Route::match(['put', 'delete'], '/',
function() {
return 'Hello World';
});
HTTP METHODS
• GET : used to retrieve (or read) a representation of a
resource. Return 200 OK or 404 NOT FOUND or 400
BAD REQUEST
• POST : used to create new resources. Return 201 OK
or 404 NOT FOUND
• PUT : used to update existing resource. Return 200 OK
or 204 NO CONTENT or 404 NOT FOUND
• DELETE : used to delete existing resource. Return 200
OK or 404 NOT FOUND
http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
CODING TIME!
• Open app/Http/routes.php
• Insert couple of routes
Route::get('tesget', function()
{
return 'Hello World';
});
Route::post('tespost', function()
{
return 'Hello World';
});
Route::any('tesany', function()
{
return 'Hello World';
});
Route::match(['put', 'delete'], 

'tesmatch', function() {
return 'Hello World';
});
CODING TIME!
• Insert -> Route::resource(‘welcome’,
‘WelcomeController');
• Go to terminal / command line.
• Type php artisan route:list
Laravel Controller
Instead of defining all of your request handling logic in a single
routes.php file, you may wish to organize this behavior using
Controller classes. Controllers can group related HTTP request
handling logic into a class. Controllers are typically stored in the
app/Http/Controllers directory.
http://laravel.com/docs/5.0/controllers
CODING TIME!
• go to app/Http/Controller
• create new Controller class (DummyController.php)
• go to app/Http/routes.php
• insert -> Route::get(‘dummy’,
‘DummyController@index‘);
CODING TIME!
• php artisan make:controller Dummy2Controller
• go to app/Http/routes.php
• insert -> Route::resource(‘dummy2’,
‘Dummy2Controller');
Laravel Model
A Model should contain all of the Business Logic of your
application. Or in other words, how the application interacts with
the database.
http://laravel.com/docs/5.0/database
The database configuration file is config/database.php
DB::select('select * from users where id = :id', ['id' => 1]);
DB::insert('insert into users (id, name) values (?, ?)', [1, 'Dayle']);
DB::update('update users set votes = 100 where name = ?', ['John']);
DB::delete('delete from users');
DB::statement('drop table users');
Query Builder
The database query builder provides a convenient, fluent
interface to creating and running database queries. It can be
used to perform most database operations in your application,
and works on all supported database systems.
http://laravel.com/docs/5.0/queries
DB::table('users')->get();
DB::table('users')->insert(
['email' => 'john@example.com', 'votes' => 0]
);
DB::table('users')
->where('id', 1)
->update(['votes' => 1]);
DB::table('users')->where('votes', '<', 100)->delete();
Eloquent ORM
The Eloquent ORM included with Laravel provides a beautiful,
simple ActiveRecord implementation for working with your
database. Each database table has a corresponding "Model"
which is used to interact with that table.
http://laravel.com/docs/5.0/eloquent
class User extends Model {}
php artisan make:model User
class User extends Model {
protected $table = 'my_users';
}
$users = User::all();
$model = User::where('votes', '>', 100)->firstOrFail();
Schema Builder
The Laravel Schema class provides a database agnostic way of
manipulating tables. It works well with all of the databases
supported by Laravel, and has a unified API across all of these
systems.
http://laravel.com/docs/5.0/schema
Schema::create('users', function($table)
{
$table->increments('id');
});
Schema::rename($from, $to);
Schema::drop('users');
Migrations & Seeding
Migrations are a type of version control for your database. They
allow a team to modify the database schema and stay up to date
on the current schema state. Migrations are typically paired with
the Schema Builder to easily manage your application's schema.
http://laravel.com/docs/5.0/migrations
php artisan make:migration create_users_table
class UserTableSeeder extends Seeder {
public function run()
{
DB::table('users')->delete();
User::create(['email' => 'foo@bar.com']);
}
}
php artisan db:seed
php artisan migrate --force
CODING TIME!
• go to env.example, rename it to .env
• set DB_HOST=localhost
• set DB_DATABASE=yourdbname
• set DB_USERNAME=yourdbusername
• set DB_PASSWORD=yourdbpassword
CODING TIME!
run php artisan make:migration create_sample_table
run php artisan migrate
CODING TIME!
create SampleTableSeeder.php
run php artisan db:seed
run composer dump-autoload
CODING TIME!
run php artisan make:model Sample
run composer migrate
edit app/Sample.php
Laravel View
Views contain the HTML served by your application, and serve
as a convenient method of separating your controller and
domain logic from your presentation logic. Views are stored in
the resources/views directory.
http://laravel.com/docs/5.0/views
CODING TIME!
create resources/views/sample.php
create app/Http/controllers/SampleController.php
register the route in app/Http/routes.php

Mais conteúdo relacionado

Mais procurados

Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Lorvent56
 
Laravel Restful API and AngularJS
Laravel Restful API and AngularJSLaravel Restful API and AngularJS
Laravel Restful API and AngularJS
Blake Newman
 

Mais procurados (20)

Intro to Laravel
Intro to LaravelIntro to Laravel
Intro to Laravel
 
A introduction to Laravel framework
A introduction to Laravel frameworkA introduction to Laravel framework
A introduction to Laravel framework
 
Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1Laravel Beginners Tutorial 1
Laravel Beginners Tutorial 1
 
Web Development with Laravel 5
Web Development with Laravel 5Web Development with Laravel 5
Web Development with Laravel 5
 
Knowing Laravel 5 : The most popular PHP framework
Knowing Laravel 5 : The most popular PHP frameworkKnowing Laravel 5 : The most popular PHP framework
Knowing Laravel 5 : The most popular PHP framework
 
Laravel 5
Laravel 5Laravel 5
Laravel 5
 
Laravel presentation
Laravel presentationLaravel presentation
Laravel presentation
 
Laravel - Website Development in Php Framework.
Laravel - Website Development in Php Framework.Laravel - Website Development in Php Framework.
Laravel - Website Development in Php Framework.
 
Laravel Introduction
Laravel IntroductionLaravel Introduction
Laravel Introduction
 
10 Laravel packages everyone should know
10 Laravel packages everyone should know10 Laravel packages everyone should know
10 Laravel packages everyone should know
 
Presentation laravel 5 4
Presentation laravel 5 4Presentation laravel 5 4
Presentation laravel 5 4
 
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
 
Laravel 5.4
Laravel 5.4 Laravel 5.4
Laravel 5.4
 
All Aboard for Laravel 5.1
All Aboard for Laravel 5.1All Aboard for Laravel 5.1
All Aboard for Laravel 5.1
 
Laravel Restful API and AngularJS
Laravel Restful API and AngularJSLaravel Restful API and AngularJS
Laravel Restful API and AngularJS
 
Laravel Beginners Tutorial 2
Laravel Beginners Tutorial 2Laravel Beginners Tutorial 2
Laravel Beginners Tutorial 2
 
API Development with Laravel
API Development with LaravelAPI Development with Laravel
API Development with Laravel
 
Laravel ppt
Laravel pptLaravel ppt
Laravel ppt
 
All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$All the Laravel things: up and running to making $$
All the Laravel things: up and running to making $$
 
What's New in Laravel 5 (Laravel Meetup - 23th Apr 15, Yogyakarta, ID)
What's New in Laravel 5 (Laravel Meetup - 23th Apr 15, Yogyakarta, ID)What's New in Laravel 5 (Laravel Meetup - 23th Apr 15, Yogyakarta, ID)
What's New in Laravel 5 (Laravel Meetup - 23th Apr 15, Yogyakarta, ID)
 

Semelhante a Getting to know Laravel 5

nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
WalaSidhom1
 
Lecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptxLecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptx
SaziaRahman
 
Rapid API Development ArangoDB Foxx
Rapid API Development ArangoDB FoxxRapid API Development ArangoDB Foxx
Rapid API Development ArangoDB Foxx
Michael Hackstein
 

Semelhante a Getting to know Laravel 5 (20)

REST APIs in Laravel 101
REST APIs in Laravel 101REST APIs in Laravel 101
REST APIs in Laravel 101
 
Web services with laravel
Web services with laravelWeb services with laravel
Web services with laravel
 
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
 
Web service with Laravel
Web service with LaravelWeb service with Laravel
Web service with Laravel
 
Introduction to Laravel
Introduction to LaravelIntroduction to Laravel
Introduction to Laravel
 
nodejs_at_a_glance.ppt
nodejs_at_a_glance.pptnodejs_at_a_glance.ppt
nodejs_at_a_glance.ppt
 
Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Rack
 
CakePHP
CakePHPCakePHP
CakePHP
 
Laravel Meetup
Laravel MeetupLaravel Meetup
Laravel Meetup
 
PHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckPHP from soup to nuts Course Deck
PHP from soup to nuts Course Deck
 
Rails 4.0
Rails 4.0Rails 4.0
Rails 4.0
 
Lecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptxLecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptx
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
Laravel 5
Laravel 5Laravel 5
Laravel 5
 
ITB2016 - Building ColdFusion RESTFul Services
ITB2016 - Building ColdFusion RESTFul ServicesITB2016 - Building ColdFusion RESTFul Services
ITB2016 - Building ColdFusion RESTFul Services
 
Using and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middlewareUsing and scaling Rack and Rack-based middleware
Using and scaling Rack and Rack-based middleware
 
Laravel intake 37 all days
Laravel intake 37 all daysLaravel intake 37 all days
Laravel intake 37 all days
 
Day02 a pi.
Day02   a pi.Day02   a pi.
Day02 a pi.
 
Rapid API Development ArangoDB Foxx
Rapid API Development ArangoDB FoxxRapid API Development ArangoDB Foxx
Rapid API Development ArangoDB Foxx
 

Último

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 

Último (20)

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 

Getting to know Laravel 5

  • 2. What is Laravel? • PHP Framework • Most popular on Github • MVC Architecture • MIT License
  • 3. Why Laravel? • Composer • Community • Code Construction
  • 5. Requirements • Composer • Local server (with XAMPP, WAMP, MAMP, etc) • PHP 5.4+ • Mcrypt, OpenSSL, Mbstring, Tokenizer & PHP JSON extension
  • 6. COMPOSER Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you. 
 https://getcomposer.org UNIX : curl -sS https://getcomposer.org/installer | php WIN : https://getcomposer.org/Composer-Setup.exe
  • 7. Installing Laravel Composer Global : composer create-project laravel/laravel —- prefer-dist foldername Composer Local : php /path/to/composer.phar create-project laravel/laravel --prefer-dist foldername
  • 8. Fix Folder Permission • Set storage folder to be writable (777) • Set vendor folder to be writable (777)
  • 9.
  • 11. Laravel Artisan Artisan is the name of the command-line interface included with Laravel. It provides a number of helpful commands for your use while developing your application. It is driven by the powerful Symfony Console component. php artisan list : 
 list all available artisan command php artisan help [command] : 
 help information for each command http://laravel.com/docs/5.0/artisan
  • 12. Laravel Routing Routing is the process of taking a URI endpoint (that part of the URI which comes after the base URL) and decomposing it into parameters to determine which module, controller, and action of that controller should receive the request. http://laravel.com/docs/5.0/routing Route::get('/', function() { return 'Hello World'; }); Route::post('foo/bar', function() { return 'Hello World'; }); Route::any('foo', function() { return 'Hello World'; }); Route::match(['put', 'delete'], '/', function() { return 'Hello World'; });
  • 13. HTTP METHODS • GET : used to retrieve (or read) a representation of a resource. Return 200 OK or 404 NOT FOUND or 400 BAD REQUEST • POST : used to create new resources. Return 201 OK or 404 NOT FOUND • PUT : used to update existing resource. Return 200 OK or 204 NO CONTENT or 404 NOT FOUND • DELETE : used to delete existing resource. Return 200 OK or 404 NOT FOUND http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
  • 14. CODING TIME! • Open app/Http/routes.php • Insert couple of routes Route::get('tesget', function() { return 'Hello World'; }); Route::post('tespost', function() { return 'Hello World'; }); Route::any('tesany', function() { return 'Hello World'; }); Route::match(['put', 'delete'], 
 'tesmatch', function() { return 'Hello World'; });
  • 15. CODING TIME! • Insert -> Route::resource(‘welcome’, ‘WelcomeController'); • Go to terminal / command line. • Type php artisan route:list
  • 16. Laravel Controller Instead of defining all of your request handling logic in a single routes.php file, you may wish to organize this behavior using Controller classes. Controllers can group related HTTP request handling logic into a class. Controllers are typically stored in the app/Http/Controllers directory. http://laravel.com/docs/5.0/controllers
  • 17. CODING TIME! • go to app/Http/Controller • create new Controller class (DummyController.php) • go to app/Http/routes.php • insert -> Route::get(‘dummy’, ‘DummyController@index‘);
  • 18. CODING TIME! • php artisan make:controller Dummy2Controller • go to app/Http/routes.php • insert -> Route::resource(‘dummy2’, ‘Dummy2Controller');
  • 19. Laravel Model A Model should contain all of the Business Logic of your application. Or in other words, how the application interacts with the database. http://laravel.com/docs/5.0/database The database configuration file is config/database.php DB::select('select * from users where id = :id', ['id' => 1]); DB::insert('insert into users (id, name) values (?, ?)', [1, 'Dayle']); DB::update('update users set votes = 100 where name = ?', ['John']); DB::delete('delete from users'); DB::statement('drop table users');
  • 20. Query Builder The database query builder provides a convenient, fluent interface to creating and running database queries. It can be used to perform most database operations in your application, and works on all supported database systems. http://laravel.com/docs/5.0/queries DB::table('users')->get(); DB::table('users')->insert( ['email' => 'john@example.com', 'votes' => 0] ); DB::table('users') ->where('id', 1) ->update(['votes' => 1]); DB::table('users')->where('votes', '<', 100)->delete();
  • 21. Eloquent ORM The Eloquent ORM included with Laravel provides a beautiful, simple ActiveRecord implementation for working with your database. Each database table has a corresponding "Model" which is used to interact with that table. http://laravel.com/docs/5.0/eloquent class User extends Model {} php artisan make:model User class User extends Model { protected $table = 'my_users'; } $users = User::all(); $model = User::where('votes', '>', 100)->firstOrFail();
  • 22. Schema Builder The Laravel Schema class provides a database agnostic way of manipulating tables. It works well with all of the databases supported by Laravel, and has a unified API across all of these systems. http://laravel.com/docs/5.0/schema Schema::create('users', function($table) { $table->increments('id'); }); Schema::rename($from, $to); Schema::drop('users');
  • 23. Migrations & Seeding Migrations are a type of version control for your database. They allow a team to modify the database schema and stay up to date on the current schema state. Migrations are typically paired with the Schema Builder to easily manage your application's schema. http://laravel.com/docs/5.0/migrations php artisan make:migration create_users_table class UserTableSeeder extends Seeder { public function run() { DB::table('users')->delete(); User::create(['email' => 'foo@bar.com']); } } php artisan db:seed php artisan migrate --force
  • 24. CODING TIME! • go to env.example, rename it to .env • set DB_HOST=localhost • set DB_DATABASE=yourdbname • set DB_USERNAME=yourdbusername • set DB_PASSWORD=yourdbpassword
  • 25. CODING TIME! run php artisan make:migration create_sample_table run php artisan migrate
  • 26. CODING TIME! create SampleTableSeeder.php run php artisan db:seed run composer dump-autoload
  • 27. CODING TIME! run php artisan make:model Sample run composer migrate edit app/Sample.php
  • 28. Laravel View Views contain the HTML served by your application, and serve as a convenient method of separating your controller and domain logic from your presentation logic. Views are stored in the resources/views directory. http://laravel.com/docs/5.0/views
  • 29. CODING TIME! create resources/views/sample.php create app/Http/controllers/SampleController.php register the route in app/Http/routes.php