SlideShare a Scribd company logo
1 of 63
Workshop Laravel 5.2
27 February 2016
STT NF, Jakarta Selatan
Hello!
Wahyu Rismawan
Informatics Eng, Telkom University (2011)
Software Artisan at Badr Interactive
~3 years exp in Web Development
Stalk:
Linkedin: bit.ly/wrismawan
FB: fb.com/wahyu.rismawan
Ready?
Preparation
• PHP >= 5.5.9 on XAMPP
• Already installed Composer (PHP Dependency
Manager)
• Terminal / Command Prompt
• Text Editor
Composer?
Is he musician? Hmmm...
Composer is a tool for
dependency manager in PHP
Your
Awesome
PHP
Project
(1) Read composer.json
(2) Find Library form Packagist
(3) Download Library(4) Library downloaded
on your project
How Composer Works?
Installation for OSX - Windows - Linux
https://getcomposer.org/doc/00-intro.md
How to use Composer?
Let’s install Laravel using Composer!
composer create-project --prefer-dist laravel/laravel PROJECT_NAME
1) cd PROJECT_NAME
2) php artisan serve
Run your Project
http://localhost:8000
Congratulation! It should be…
Small Intro into MVC (Model-View-Controller)
Image source: http://www.meteorfury.com/2014/04/objective-c/model-view-controller-mvc-design-pattern/
Small Intro into MVC (Model-View-Controller)
Image source: http://www.meteorfury.com/2014/04/objective-c/model-view-controller-mvc-design-pattern/
“Model” Example
Directory for “Controller codes”
Directory for “View codes”
Feeling dizzy or confused?
Don’t talk to much. Let’s practice!
Your first awesome Larevel app:
Inspire (Quote sharing platform)
Features:
- Authentication (Register, Login, Logout)
- Create, Update and Delete Quote
- Quote Timeline (Display quote from all users)
- Like Quote
Create Database
Inspire: Design Database
Review: Create Table using migrations
1) Create migration file
php artisan make:migration create_{name}_table
2) Code your table schema
3) To generata table, run: php artisan migrate
DB Config: Preparing database
• Create DB via phpmyadmin, e.g: “workshop”
• Config .env file
DB_HOST=localhost:8889
DB_DATABASE=workshop
DB_USERNAME=root
DB_PASSWORD=root
DB Config: Create migration for Quotes
php artisan make:migration create_quotes_table
Schema::create('quotes', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id');
$table->string('content');
$table->string('author');
$table->timestamps();
});
DB Config: Create migration for Likes
php artisan make:migration create_likes_table
Schema::create('likes', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id');
$table->integer('quote_id');
$table->timestamps();
});
DB Config: Create Table Users
We don’t need to do anything,
Because Laravel have made users migration files (?)
2014_10_12_000000_create_users_table.php
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password', 60);
$table->rememberToken();
$table->timestamps();
});
Ready to create table
php artisan migrate
Will generate table to database based on our
migration files just made
Review: Create Table using migrations
1) Create migration file
php artisan make:migration create_{name}_table
2) Code your table schema
3) To generata table, run: php artisan migrate
Your first awesome Larevel app:
Inspire (Quote sharing platform)
Features:
- Authentication (Register, Login, Logout)
- Create, Update and Delete Quote
- Quote Timeline (Display quote from all users)
- Like Quote
Feature: Authentication
(Register, Login, Logout)
Create Login, Logout and Register
using “Laravel Magic”
php artisan make:auth
Will generate: view, controller and route for register,
login and logout
How can it work?
Is there ‘/home’ in
routes.php?
HTTP Request -> localhost:8000/home
Route::get(‘/home’, ‘HomeController@index’)
App/Http/Controllers/HomeController.php
Resources/views/home.blade.php
Render view
Load controller
HTTP Response
Find route
Your first awesome Larevel app:
Inspire (Quote sharing platform)
Features:
- Authentication (Register, Login, Logout)
- CRUD (Create, Retrieve, Update and Delete)
Quote
- Quote Timeline (Display quote from all users)
- Like Quote
CRUD for Quote
General Steps
2) Create controller
php artisan make:controller YourNewController
1) Define new feature route in routes.php
4) If needed, create model
php artisan make:model NewModelName
3) Create view using blade in resources/views
Define new feature routing
Route::get('/quote/timeline', 'QuoteController@timeline');
Route::post('/quote/save', 'QuoteController@store');
Route::get('/quote/edit/{id}', 'QuoteController@edit');
Route::post('/quote/update/{id}', 'QuoteController@update');
Open routes.php in App/Http/routes.php
Add this following code into routes.php
Create Quote Controller
php artisan make:controller QuoteController
View for Quote Timeline
Create timeline.blade.php at directory resources/views
Controller for Quote Timeline
Open QuoteController at directory App/Http/Controllers
It will refer to timeline.blade.php
Model for Quote
Create Quote Model: php artisan make:model Quote
Controller for storing new Quote
Open QuoteController at directory App/Http/Controllers
Display Quotes from all users
Open QuoteController at directory App/Http/Controllers
Display Quotes from all users
Open timeline.blade.php at directory resources/views
View for Edit & Remove Quote
View for Edit & Remove Quote
Open timeline.blade.php at directory resources/views
View for Edit Quote
View for Edit Quote
create edit_quote.blade.php at directory resources/views
Controller for Edit Quote
Open QuoteController at directory App/Http/Controllers
Controller for Update Quote
Open QuoteController at directory App/Http/Controllers
Controller for Delete Quote
Open QuoteController at directory App/Http/Controllers
Your first awesome Larevel app:
Inspire (Quote sharing platform)
Features:
- Authentication (Register, Login, Logout)
- CRUD (Create, Retrieve, Update and Delete)
Quote
- Quote Timeline (Display quote from all users)
- Like Quote
General Steps
3) Create controller for handling Like request
php artisan make:controller LikeController
1) Define new route in routes.php
2) Create Like Model
php artisan make:model Like
4) We’d already made view for Like at prev step.
Define new feature routing
Route::get('/like/{quote_id}', ’LikeController@like');
Route::get('/unlike/{quote_id}', ’LikeController@unlike');
Open routes.php from App/Http/routes.php
Add this following code into routes.php
Create Quote Model
php artisan make:model Like
Add Like relation in Quote Model
Open Quote.php from App/, add function likes()
Add Like relation in Quote Model
Open Quote.php from App/ then add function likes()
Create Like Controller
php artisan make:controller LikeController
Handling View for Like/Unlike Request
Open timeline.blade.php from resources/views
Controller for like request
Open LikeController from App/Http/Controllers
Don’t forget to add use App/Quote at the top
Add static function to check “user like”
Open Quote.php from App/
Don’t forget to add use Auth; at the top
Controller for unlike request
Open LikeController from App/Http/Controllers
Let’s see.
Any questions?

More Related Content

What's hot

Laravel Beginners Tutorial 2
Laravel Beginners Tutorial 2Laravel Beginners Tutorial 2
Laravel Beginners Tutorial 2Vikas Chauhan
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5Darren Craig
 
Laravel 5 In Depth
Laravel 5 In DepthLaravel 5 In Depth
Laravel 5 In DepthKirk Bushell
 
10 Laravel packages everyone should know
10 Laravel packages everyone should know10 Laravel packages everyone should know
10 Laravel packages everyone should knowPovilas Korop
 
Introduction to laravel framework
Introduction to laravel frameworkIntroduction to laravel framework
Introduction to laravel frameworkAhmad Fatoni
 
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 5 Annotations: RESTful API routing
Laravel 5 Annotations: RESTful API routingLaravel 5 Annotations: RESTful API routing
Laravel 5 Annotations: RESTful API routingChristopher Pecoraro
 
Laravel presentation
Laravel presentationLaravel presentation
Laravel presentationToufiq Mahmud
 
Web Development with Laravel 5
Web Development with Laravel 5Web Development with Laravel 5
Web Development with Laravel 5Soheil Khodayari
 
All Aboard for Laravel 5.1
All Aboard for Laravel 5.1All Aboard for Laravel 5.1
All Aboard for Laravel 5.1Jason McCreary
 
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 $$Joe Ferguson
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionJoe Ferguson
 
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 frameworkBukhori Aqid
 
A introduction to Laravel framework
A introduction to Laravel frameworkA introduction to Laravel framework
A introduction to Laravel frameworkPhu Luong Trong
 

What's hot (20)

Laravel Beginners Tutorial 2
Laravel Beginners Tutorial 2Laravel Beginners Tutorial 2
Laravel Beginners Tutorial 2
 
Why Laravel?
Why Laravel?Why Laravel?
Why Laravel?
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5
 
Laravel 5 In Depth
Laravel 5 In DepthLaravel 5 In Depth
Laravel 5 In Depth
 
Intro to Laravel
Intro to LaravelIntro to Laravel
Intro to Laravel
 
Laravel 5.4
Laravel 5.4 Laravel 5.4
Laravel 5.4
 
10 Laravel packages everyone should know
10 Laravel packages everyone should know10 Laravel packages everyone should know
10 Laravel packages everyone should know
 
Laravel 5
Laravel 5Laravel 5
Laravel 5
 
Introduction to laravel framework
Introduction to laravel frameworkIntroduction to laravel framework
Introduction to laravel framework
 
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 Annotations: RESTful API routing
Laravel 5 Annotations: RESTful API routingLaravel 5 Annotations: RESTful API routing
Laravel 5 Annotations: RESTful API routing
 
Laravel presentation
Laravel presentationLaravel presentation
Laravel presentation
 
Intro to Laravel 4
Intro to Laravel 4Intro to Laravel 4
Intro to Laravel 4
 
Web Development with Laravel 5
Web Development with Laravel 5Web Development with Laravel 5
Web Development with Laravel 5
 
All Aboard for Laravel 5.1
All Aboard for Laravel 5.1All Aboard for Laravel 5.1
All Aboard for Laravel 5.1
 
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 $$
 
Laravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello ProductionLaravel Forge: Hello World to Hello Production
Laravel Forge: Hello World to Hello Production
 
Laravel Introduction
Laravel IntroductionLaravel Introduction
Laravel Introduction
 
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
 
A introduction to Laravel framework
A introduction to Laravel frameworkA introduction to Laravel framework
A introduction to Laravel framework
 

Similar to Workshop Laravel 5.2

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...Dilouar Hossain
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php PresentationAlan Pinstein
 
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
 
Laravel 5 New Features
Laravel 5 New FeaturesLaravel 5 New Features
Laravel 5 New FeaturesJoe Ferguson
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteorSapna Upreti
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroRESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroChristopher Pecoraro
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfonyFrancois Zaninotto
 
Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestJoshua Warren
 
Getting Started with Zend Framework
Getting Started with Zend FrameworkGetting Started with Zend Framework
Getting Started with Zend FrameworkJuan Antonio
 
Make your application expressive
Make your application expressiveMake your application expressive
Make your application expressiveChristian Varela
 
Introduction to Shiny for building web apps in R
Introduction to Shiny for building web apps in RIntroduction to Shiny for building web apps in R
Introduction to Shiny for building web apps in RPaul Richards
 
Rits Brown Bag - Salesforce Lightning
Rits Brown Bag - Salesforce LightningRits Brown Bag - Salesforce Lightning
Rits Brown Bag - Salesforce LightningRight IT Services
 
CONTENT MANAGEMENT SYSTEM
CONTENT MANAGEMENT SYSTEMCONTENT MANAGEMENT SYSTEM
CONTENT MANAGEMENT SYSTEMANAND PRAKASH
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterHaehnchen
 

Similar to Workshop Laravel 5.2 (20)

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...
 
My Saminar On Php
My Saminar On PhpMy Saminar On Php
My Saminar On Php
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
Laravel 5
Laravel 5Laravel 5
Laravel 5
 
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 New Features
Laravel 5 New FeaturesLaravel 5 New Features
Laravel 5 New Features
 
Reactive application using meteor
Reactive application using meteorReactive application using meteor
Reactive application using meteor
 
RESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher PecoraroRESTful API development in Laravel 4 - Christopher Pecoraro
RESTful API development in Laravel 4 - Christopher Pecoraro
 
Simplify your professional web development with symfony
Simplify your professional web development with symfonySimplify your professional web development with symfony
Simplify your professional web development with symfony
 
Day02 a pi.
Day02   a pi.Day02   a pi.
Day02 a pi.
 
Elefrant [ng-Poznan]
Elefrant [ng-Poznan]Elefrant [ng-Poznan]
Elefrant [ng-Poznan]
 
Behavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWestBehavior & Specification Driven Development in PHP - #OpenWest
Behavior & Specification Driven Development in PHP - #OpenWest
 
Getting Started with Zend Framework
Getting Started with Zend FrameworkGetting Started with Zend Framework
Getting Started with Zend Framework
 
Make your application expressive
Make your application expressiveMake your application expressive
Make your application expressive
 
Introduction to Shiny for building web apps in R
Introduction to Shiny for building web apps in RIntroduction to Shiny for building web apps in R
Introduction to Shiny for building web apps in R
 
Rits Brown Bag - Salesforce Lightning
Rits Brown Bag - Salesforce LightningRits Brown Bag - Salesforce Lightning
Rits Brown Bag - Salesforce Lightning
 
Dev streams2
Dev streams2Dev streams2
Dev streams2
 
CONTENT MANAGEMENT SYSTEM
CONTENT MANAGEMENT SYSTEMCONTENT MANAGEMENT SYSTEM
CONTENT MANAGEMENT SYSTEM
 
Supa fast Ruby + Rails
Supa fast Ruby + RailsSupa fast Ruby + Rails
Supa fast Ruby + Rails
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 

Recently uploaded

CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceBrainSell Technologies
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...Akihiro Suda
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identityteam-WIBU
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 

Recently uploaded (20)

CRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. SalesforceCRM Contender Series: HubSpot vs. Salesforce
CRM Contender Series: HubSpot vs. Salesforce
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
20240415 [Container Plumbing Days] Usernetes Gen2 - Kubernetes in Rootless Do...
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva2.pdf Ejercicios de programación competitiva
2.pdf Ejercicios de programación competitiva
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
Post Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on IdentityPost Quantum Cryptography – The Impact on Identity
Post Quantum Cryptography – The Impact on Identity
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 

Workshop Laravel 5.2

  • 1. Workshop Laravel 5.2 27 February 2016 STT NF, Jakarta Selatan
  • 2. Hello! Wahyu Rismawan Informatics Eng, Telkom University (2011) Software Artisan at Badr Interactive ~3 years exp in Web Development Stalk: Linkedin: bit.ly/wrismawan FB: fb.com/wahyu.rismawan
  • 4. Preparation • PHP >= 5.5.9 on XAMPP • Already installed Composer (PHP Dependency Manager) • Terminal / Command Prompt • Text Editor
  • 6. Composer is a tool for dependency manager in PHP
  • 7. Your Awesome PHP Project (1) Read composer.json (2) Find Library form Packagist (3) Download Library(4) Library downloaded on your project How Composer Works?
  • 8. Installation for OSX - Windows - Linux https://getcomposer.org/doc/00-intro.md
  • 9. How to use Composer?
  • 10. Let’s install Laravel using Composer!
  • 11. composer create-project --prefer-dist laravel/laravel PROJECT_NAME
  • 12. 1) cd PROJECT_NAME 2) php artisan serve Run your Project http://localhost:8000
  • 14. Small Intro into MVC (Model-View-Controller) Image source: http://www.meteorfury.com/2014/04/objective-c/model-view-controller-mvc-design-pattern/
  • 15. Small Intro into MVC (Model-View-Controller) Image source: http://www.meteorfury.com/2014/04/objective-c/model-view-controller-mvc-design-pattern/ “Model” Example Directory for “Controller codes” Directory for “View codes”
  • 16. Feeling dizzy or confused?
  • 17. Don’t talk to much. Let’s practice!
  • 18. Your first awesome Larevel app: Inspire (Quote sharing platform) Features: - Authentication (Register, Login, Logout) - Create, Update and Delete Quote - Quote Timeline (Display quote from all users) - Like Quote
  • 21. Review: Create Table using migrations 1) Create migration file php artisan make:migration create_{name}_table 2) Code your table schema 3) To generata table, run: php artisan migrate
  • 22. DB Config: Preparing database • Create DB via phpmyadmin, e.g: “workshop” • Config .env file DB_HOST=localhost:8889 DB_DATABASE=workshop DB_USERNAME=root DB_PASSWORD=root
  • 23. DB Config: Create migration for Quotes php artisan make:migration create_quotes_table Schema::create('quotes', function (Blueprint $table) { $table->increments('id'); $table->integer('user_id'); $table->string('content'); $table->string('author'); $table->timestamps(); });
  • 24. DB Config: Create migration for Likes php artisan make:migration create_likes_table Schema::create('likes', function (Blueprint $table) { $table->increments('id'); $table->integer('user_id'); $table->integer('quote_id'); $table->timestamps(); });
  • 25. DB Config: Create Table Users We don’t need to do anything, Because Laravel have made users migration files (?) 2014_10_12_000000_create_users_table.php Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password', 60); $table->rememberToken(); $table->timestamps(); });
  • 26. Ready to create table php artisan migrate Will generate table to database based on our migration files just made
  • 27. Review: Create Table using migrations 1) Create migration file php artisan make:migration create_{name}_table 2) Code your table schema 3) To generata table, run: php artisan migrate
  • 28. Your first awesome Larevel app: Inspire (Quote sharing platform) Features: - Authentication (Register, Login, Logout) - Create, Update and Delete Quote - Quote Timeline (Display quote from all users) - Like Quote
  • 30. Create Login, Logout and Register using “Laravel Magic” php artisan make:auth Will generate: view, controller and route for register, login and logout
  • 31. How can it work?
  • 32. Is there ‘/home’ in routes.php? HTTP Request -> localhost:8000/home Route::get(‘/home’, ‘HomeController@index’) App/Http/Controllers/HomeController.php Resources/views/home.blade.php Render view Load controller HTTP Response Find route
  • 33. Your first awesome Larevel app: Inspire (Quote sharing platform) Features: - Authentication (Register, Login, Logout) - CRUD (Create, Retrieve, Update and Delete) Quote - Quote Timeline (Display quote from all users) - Like Quote
  • 35. General Steps 2) Create controller php artisan make:controller YourNewController 1) Define new feature route in routes.php 4) If needed, create model php artisan make:model NewModelName 3) Create view using blade in resources/views
  • 36. Define new feature routing Route::get('/quote/timeline', 'QuoteController@timeline'); Route::post('/quote/save', 'QuoteController@store'); Route::get('/quote/edit/{id}', 'QuoteController@edit'); Route::post('/quote/update/{id}', 'QuoteController@update'); Open routes.php in App/Http/routes.php Add this following code into routes.php
  • 37. Create Quote Controller php artisan make:controller QuoteController
  • 38. View for Quote Timeline Create timeline.blade.php at directory resources/views
  • 39.
  • 40. Controller for Quote Timeline Open QuoteController at directory App/Http/Controllers It will refer to timeline.blade.php
  • 41. Model for Quote Create Quote Model: php artisan make:model Quote
  • 42. Controller for storing new Quote Open QuoteController at directory App/Http/Controllers
  • 43. Display Quotes from all users Open QuoteController at directory App/Http/Controllers
  • 44. Display Quotes from all users Open timeline.blade.php at directory resources/views
  • 45. View for Edit & Remove Quote
  • 46. View for Edit & Remove Quote Open timeline.blade.php at directory resources/views
  • 47. View for Edit Quote
  • 48. View for Edit Quote create edit_quote.blade.php at directory resources/views
  • 49. Controller for Edit Quote Open QuoteController at directory App/Http/Controllers
  • 50. Controller for Update Quote Open QuoteController at directory App/Http/Controllers
  • 51. Controller for Delete Quote Open QuoteController at directory App/Http/Controllers
  • 52. Your first awesome Larevel app: Inspire (Quote sharing platform) Features: - Authentication (Register, Login, Logout) - CRUD (Create, Retrieve, Update and Delete) Quote - Quote Timeline (Display quote from all users) - Like Quote
  • 53. General Steps 3) Create controller for handling Like request php artisan make:controller LikeController 1) Define new route in routes.php 2) Create Like Model php artisan make:model Like 4) We’d already made view for Like at prev step.
  • 54. Define new feature routing Route::get('/like/{quote_id}', ’LikeController@like'); Route::get('/unlike/{quote_id}', ’LikeController@unlike'); Open routes.php from App/Http/routes.php Add this following code into routes.php
  • 55. Create Quote Model php artisan make:model Like
  • 56. Add Like relation in Quote Model Open Quote.php from App/, add function likes()
  • 57. Add Like relation in Quote Model Open Quote.php from App/ then add function likes()
  • 58. Create Like Controller php artisan make:controller LikeController
  • 59. Handling View for Like/Unlike Request Open timeline.blade.php from resources/views
  • 60. Controller for like request Open LikeController from App/Http/Controllers Don’t forget to add use App/Quote at the top
  • 61. Add static function to check “user like” Open Quote.php from App/ Don’t forget to add use Auth; at the top
  • 62. Controller for unlike request Open LikeController from App/Http/Controllers