SlideShare a Scribd company logo
Laravel Level 1
The Laravel Basic
By Spicydog (7-11-2016)
Agenda
● Prerequisites
● Directory Structure
● Route
● View
○ Blade
● Model
○ Migration
○ Eloquence
● Controller
○ Resource Controller
● Workshop & Assignments
● PHP-CLI
● LAMP Server
● Installed Laravel
● PHP IDE
Prerequisites
These are what you must know today
● app
● app/Http
● app/Http/Controllers
● app/*.php
● config
● database
● public
● public/index.php
● resources
● resources/views
● routes
● routes/web.php
Laravel: Directory Structure
https://laravel.com/docs/5.3/structure
Laravel: Route
● Route control what URL on what to do
● We are mainly use routes/web.php
● For get request at URI / do return view name welcome
● Common HTTP Methods: GET, POST, PUT, PATCH, DELETE
1. Route::get('/', function () {
2. return view('welcome');
3. });
Laravel: View
● View is a HTML template to display to users
● View are stored in resources/views/**/*.php
● To call view, use the function view('VIEW_PATH.VIEW_NAME', [PARAM]);
○ VIEW_PATH is directory to the view
○ VIEW_NAME is your view name, exclude .php and .blade.php
● Laravel have a template helper called blade, gonna talk later
● Now, let’s observe resources/views/welcome.blade.php together!
Laravel: Blade Template
● Blade Template is a
template helper in Laravel
● Design for easy to use and
elegant code
● Here are the common
commands we use a lot =>
● Blade template files must
have .blade.php extension
Layout
@include('VIEW')
@yield('SECTION')
@extends('LAYOUT_VIEW')
@section('SECTION'), @endsection
Echo
{{ ECHO_VARIABLE_WITH_ESCAPING_STRING }}
@{{ ECHO_RAW_STRING }}
{!! ECHO_VARIABLE_WITHOUT_ESCAPING_STRING !!}
Control
@if(), @elseif(), @else, @endif
@for(), @endfor
@foreach(), @endforeach
Explore Example run php artisan make:auth and check your views directory
Laravel: Model
● Model is where we control Database Logic
● Model files are store in app/*.php
● Model file names is Database Table Name
● We rarely use SQL in Laravel, the data record to becomes object
● We should already have app/User.php from the php artisan make:auth
● To make new model, we run php artisan make:model ModelName
Laravel: Migration
● Migration is a version control for database schema for Laravel
● This helps you create database schema via PHP Syntax
● Go check your database/migrations/*.php files
● There are function up() and down() in each migration file
● up() indicates what to do in forward
● down() indicates what to do in backward
● We have a lot of migration commands
● Setup your database configuration in .env file
● Run php artisan migrate
● Check your database schema
migrate
migrate:install Create the migration repository
migrate:refresh Reset and re-run all migrations
migrate:reset Rollback all database migrations
migrate:rollback Rollback the last database migration
migrate:status Show the status of each migration
Laravel: Eloquent
● Eloquent is an ORM (Object-relational mapping) helps you manage
database query via OOP
● 1-to-1, 1-to-many, many-to-many are also here!
● This allows us to do e.g. user->comments()->get();
to get all comments for a certain user
● Make a new record?
$newRecord = new ModelName([“FIELD”=>”DATA”]);
$newRecord->save();
● Too many things to discuss here, have a look at
https://laravel.com/docs/5.3/eloquent
Laravel: Controller
● Controller is your main logic for a certain request
● Laravel help controller to be super small compare to other frameworks
● The controller files are in app/Http/Controllers/**/*.php
● Make a new controller?
php artisan make:controller NameController
Let’s Explore Controllers
● Open app/Http/Controllers/HomeController.php
● Open routes/web.php
● Route::get('/home', 'HomeController@index');
tells laravel to run HomeController method index in /home
Laravel: Resource Controller
● As I said, Laravel is designed for productivity, it assumes that controller
would done CRUD tasks, so it has resource controller for this.
● The default functions: index, create, store, show, edit, update, destroy
● Make a new resource controller?
php artisan make:controller --resource NameController
● Map route to resource controller?
Route::resource('/name, 'NameController');
● Run php artisan route:list
Workshop & Assignment
Develop a web blog with comments with mocked user data
*Hint
- Getting a request from HTML form using $request from post route

More Related Content

PDF
Laravel level 0 (introduction)
Kriangkrai Chaonithi
 
PDF
Laravel level 2 (Let's Practical)
Kriangkrai Chaonithi
 
PDF
Laravel presentation
Toufiq Mahmud
 
PDF
Getting to know Laravel 5
Bukhori Aqid
 
PDF
Why Laravel?
Jonathan Goode
 
PDF
Web Development with Laravel 5
Soheil Khodayari
 
PPTX
Introduction to Laravel Framework (5.2)
Viral Solani
 
PPTX
Laravel ppt
Mayank Panchal
 
Laravel level 0 (introduction)
Kriangkrai Chaonithi
 
Laravel level 2 (Let's Practical)
Kriangkrai Chaonithi
 
Laravel presentation
Toufiq Mahmud
 
Getting to know Laravel 5
Bukhori Aqid
 
Why Laravel?
Jonathan Goode
 
Web Development with Laravel 5
Soheil Khodayari
 
Introduction to Laravel Framework (5.2)
Viral Solani
 
Laravel ppt
Mayank Panchal
 

What's hot (20)

PPTX
Intro to Laravel
Azukisoft Pte Ltd
 
PDF
Laravel 5 In Depth
Kirk Bushell
 
ODP
Presentation laravel 5 4
Christen Gjølbye Christensen
 
PDF
Knowing Laravel 5 : The most popular PHP framework
Bukhori Aqid
 
PPTX
Workshop Laravel 5.2
Wahyu Rismawan
 
PDF
What's New In Laravel 5
Darren Craig
 
PPT
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Lorvent56
 
PDF
All Aboard for Laravel 5.1
Jason McCreary
 
PDF
Laravel.IO A Use-Case Architecture
Shawn McCool
 
PPTX
Introduction to laravel framework
Ahmad Fatoni
 
PPTX
What's New in Laravel 5 (Laravel Meetup - 23th Apr 15, Yogyakarta, ID)
Roes Wibowo
 
PDF
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
Joe Ferguson
 
PPTX
A introduction to Laravel framework
Phu Luong Trong
 
PPTX
Laravel 5
Brian Feaver
 
PPTX
Laravel for Web Artisans
Raf Kewl
 
PPT
What Is Hobo ?
Evarist Lobo
 
PPTX
Laravel Beginners Tutorial 1
Vikas Chauhan
 
PPTX
php basics
NIRMAL FELIX
 
PPTX
Laravel5 Introduction and essentials
Pramod Kadam
 
PPTX
Building Apis in Scala with Playframework2
Manish Pandit
 
Intro to Laravel
Azukisoft Pte Ltd
 
Laravel 5 In Depth
Kirk Bushell
 
Presentation laravel 5 4
Christen Gjølbye Christensen
 
Knowing Laravel 5 : The most popular PHP framework
Bukhori Aqid
 
Workshop Laravel 5.2
Wahyu Rismawan
 
What's New In Laravel 5
Darren Craig
 
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Lorvent56
 
All Aboard for Laravel 5.1
Jason McCreary
 
Laravel.IO A Use-Case Architecture
Shawn McCool
 
Introduction to laravel framework
Ahmad Fatoni
 
What's New in Laravel 5 (Laravel Meetup - 23th Apr 15, Yogyakarta, ID)
Roes Wibowo
 
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
Joe Ferguson
 
A introduction to Laravel framework
Phu Luong Trong
 
Laravel 5
Brian Feaver
 
Laravel for Web Artisans
Raf Kewl
 
What Is Hobo ?
Evarist Lobo
 
Laravel Beginners Tutorial 1
Vikas Chauhan
 
php basics
NIRMAL FELIX
 
Laravel5 Introduction and essentials
Pramod Kadam
 
Building Apis in Scala with Playframework2
Manish Pandit
 
Ad

Similar to Laravel Level 1 (The Basic) (20)

PDF
Memphis php 01 22-13 - laravel basics
Joe Ferguson
 
PPT
Laravel & Composer presentation - extended
Cvetomir Denchev
 
PPT
Laravel & Composer presentation - WebHostFace
Cvetomir Denchev
 
PDF
Laravel
SitaPrajapati
 
ODP
Laravel 5.3 - Web Development Php framework
Swapnil Tripathi ( Looking for new challenges )
 
PPTX
PHP from soup to nuts Course Deck
rICh morrow
 
PPTX
What-is-Laravel and introduciton to Laravel
PraveenHegde20
 
PDF
Building Web Applications with Zend Framework
Phil Brown
 
PDF
Object Oriented Programming with Laravel - Session 2
Shahrzad Peyman
 
PDF
Laravel (8) php_framework_handbook__start_from_zer_18604872_(z-lib.org)
ssuser337865
 
PPTX
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Dilouar Hossain
 
PPTX
Laravel
tanveerkhan62
 
PDF
RESTful API development in Laravel 4 - Christopher Pecoraro
Christopher Pecoraro
 
PPTX
Lecture 2_ Intro to laravel.pptx
SaziaRahman
 
PDF
NodeJS
LinkMe Srl
 
PPTX
Introduction_to_Laravel_Background DOCUMENTATION.pptx
michaelcagampang4
 
PPTX
Introduction_to_Laravel_Simple DUCUMENTATION.pptx
michaelcagampang4
 
PDF
MidwestPHP 2016 - Adventures in Laravel 5
Joe Ferguson
 
PPTX
Software Development with PHP & Laravel
Juan Victor Minaya León
 
Memphis php 01 22-13 - laravel basics
Joe Ferguson
 
Laravel & Composer presentation - extended
Cvetomir Denchev
 
Laravel & Composer presentation - WebHostFace
Cvetomir Denchev
 
Laravel
SitaPrajapati
 
Laravel 5.3 - Web Development Php framework
Swapnil Tripathi ( Looking for new challenges )
 
PHP from soup to nuts Course Deck
rICh morrow
 
What-is-Laravel and introduciton to Laravel
PraveenHegde20
 
Building Web Applications with Zend Framework
Phil Brown
 
Object Oriented Programming with Laravel - Session 2
Shahrzad Peyman
 
Laravel (8) php_framework_handbook__start_from_zer_18604872_(z-lib.org)
ssuser337865
 
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Dilouar Hossain
 
Laravel
tanveerkhan62
 
RESTful API development in Laravel 4 - Christopher Pecoraro
Christopher Pecoraro
 
Lecture 2_ Intro to laravel.pptx
SaziaRahman
 
NodeJS
LinkMe Srl
 
Introduction_to_Laravel_Background DOCUMENTATION.pptx
michaelcagampang4
 
Introduction_to_Laravel_Simple DUCUMENTATION.pptx
michaelcagampang4
 
MidwestPHP 2016 - Adventures in Laravel 5
Joe Ferguson
 
Software Development with PHP & Laravel
Juan Victor Minaya León
 
Ad

Recently uploaded (20)

PDF
Micromaid: A simple Mermaid-like chart generator for Pharo
ESUG
 
PDF
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
QAware GmbH
 
PPTX
Presentation about variables and constant.pptx
safalsingh810
 
PPTX
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
PDF
Become an Agentblazer Champion Challenge Kickoff
Dele Amefo
 
PDF
Exploring AI Agents in Process Industries
amoreira6
 
PDF
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
PDF
Wondershare Filmora 14.5.20.12999 Crack Full New Version 2025
gsgssg2211
 
PDF
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
PPTX
TestNG for Java Testing and Automation testing
ssuser0213cb
 
PDF
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
ESUG
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PPTX
Presentation about variables and constant.pptx
kr2589474
 
DOCX
The Future of Smart Factories Why Embedded Analytics Leads the Way
Varsha Nayak
 
PDF
Community & News Update Q2 Meet Up 2025
VictoriaMetrics
 
PPTX
Services offered by Dynamic Solutions in Pakistan
DaniyaalAdeemShibli1
 
PDF
Why Use Open Source Reporting Tools for Business Intelligence.pdf
Varsha Nayak
 
PPTX
Role Of Python In Programing Language.pptx
jaykoshti048
 
PPTX
PFAS Reporting Requirements 2026 Are You Submission Ready Certivo.pptx
Certivo Inc
 
PDF
Jenkins: An open-source automation server powering CI/CD Automation
SaikatBasu37
 
Micromaid: A simple Mermaid-like chart generator for Pharo
ESUG
 
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
QAware GmbH
 
Presentation about variables and constant.pptx
safalsingh810
 
The-Dawn-of-AI-Reshaping-Our-World.pptxx
parthbhanushali307
 
Become an Agentblazer Champion Challenge Kickoff
Dele Amefo
 
Exploring AI Agents in Process Industries
amoreira6
 
49785682629390197565_LRN3014_Migrating_the_Beast.pdf
Abilash868456
 
Wondershare Filmora 14.5.20.12999 Crack Full New Version 2025
gsgssg2211
 
Teaching Reproducibility and Embracing Variability: From Floating-Point Exper...
University of Rennes, INSA Rennes, Inria/IRISA, CNRS
 
TestNG for Java Testing and Automation testing
ssuser0213cb
 
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
ESUG
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
Presentation about variables and constant.pptx
kr2589474
 
The Future of Smart Factories Why Embedded Analytics Leads the Way
Varsha Nayak
 
Community & News Update Q2 Meet Up 2025
VictoriaMetrics
 
Services offered by Dynamic Solutions in Pakistan
DaniyaalAdeemShibli1
 
Why Use Open Source Reporting Tools for Business Intelligence.pdf
Varsha Nayak
 
Role Of Python In Programing Language.pptx
jaykoshti048
 
PFAS Reporting Requirements 2026 Are You Submission Ready Certivo.pptx
Certivo Inc
 
Jenkins: An open-source automation server powering CI/CD Automation
SaikatBasu37
 

Laravel Level 1 (The Basic)

  • 1. Laravel Level 1 The Laravel Basic By Spicydog (7-11-2016)
  • 2. Agenda ● Prerequisites ● Directory Structure ● Route ● View ○ Blade ● Model ○ Migration ○ Eloquence ● Controller ○ Resource Controller ● Workshop & Assignments
  • 3. ● PHP-CLI ● LAMP Server ● Installed Laravel ● PHP IDE Prerequisites
  • 4. These are what you must know today ● app ● app/Http ● app/Http/Controllers ● app/*.php ● config ● database ● public ● public/index.php ● resources ● resources/views ● routes ● routes/web.php Laravel: Directory Structure https://laravel.com/docs/5.3/structure
  • 5. Laravel: Route ● Route control what URL on what to do ● We are mainly use routes/web.php ● For get request at URI / do return view name welcome ● Common HTTP Methods: GET, POST, PUT, PATCH, DELETE 1. Route::get('/', function () { 2. return view('welcome'); 3. });
  • 6. Laravel: View ● View is a HTML template to display to users ● View are stored in resources/views/**/*.php ● To call view, use the function view('VIEW_PATH.VIEW_NAME', [PARAM]); ○ VIEW_PATH is directory to the view ○ VIEW_NAME is your view name, exclude .php and .blade.php ● Laravel have a template helper called blade, gonna talk later ● Now, let’s observe resources/views/welcome.blade.php together!
  • 7. Laravel: Blade Template ● Blade Template is a template helper in Laravel ● Design for easy to use and elegant code ● Here are the common commands we use a lot => ● Blade template files must have .blade.php extension Layout @include('VIEW') @yield('SECTION') @extends('LAYOUT_VIEW') @section('SECTION'), @endsection Echo {{ ECHO_VARIABLE_WITH_ESCAPING_STRING }} @{{ ECHO_RAW_STRING }} {!! ECHO_VARIABLE_WITHOUT_ESCAPING_STRING !!} Control @if(), @elseif(), @else, @endif @for(), @endfor @foreach(), @endforeach Explore Example run php artisan make:auth and check your views directory
  • 8. Laravel: Model ● Model is where we control Database Logic ● Model files are store in app/*.php ● Model file names is Database Table Name ● We rarely use SQL in Laravel, the data record to becomes object ● We should already have app/User.php from the php artisan make:auth ● To make new model, we run php artisan make:model ModelName
  • 9. Laravel: Migration ● Migration is a version control for database schema for Laravel ● This helps you create database schema via PHP Syntax ● Go check your database/migrations/*.php files ● There are function up() and down() in each migration file ● up() indicates what to do in forward ● down() indicates what to do in backward ● We have a lot of migration commands ● Setup your database configuration in .env file ● Run php artisan migrate ● Check your database schema migrate migrate:install Create the migration repository migrate:refresh Reset and re-run all migrations migrate:reset Rollback all database migrations migrate:rollback Rollback the last database migration migrate:status Show the status of each migration
  • 10. Laravel: Eloquent ● Eloquent is an ORM (Object-relational mapping) helps you manage database query via OOP ● 1-to-1, 1-to-many, many-to-many are also here! ● This allows us to do e.g. user->comments()->get(); to get all comments for a certain user ● Make a new record? $newRecord = new ModelName([“FIELD”=>”DATA”]); $newRecord->save(); ● Too many things to discuss here, have a look at https://laravel.com/docs/5.3/eloquent
  • 11. Laravel: Controller ● Controller is your main logic for a certain request ● Laravel help controller to be super small compare to other frameworks ● The controller files are in app/Http/Controllers/**/*.php ● Make a new controller? php artisan make:controller NameController Let’s Explore Controllers ● Open app/Http/Controllers/HomeController.php ● Open routes/web.php ● Route::get('/home', 'HomeController@index'); tells laravel to run HomeController method index in /home
  • 12. Laravel: Resource Controller ● As I said, Laravel is designed for productivity, it assumes that controller would done CRUD tasks, so it has resource controller for this. ● The default functions: index, create, store, show, edit, update, destroy ● Make a new resource controller? php artisan make:controller --resource NameController ● Map route to resource controller? Route::resource('/name, 'NameController'); ● Run php artisan route:list
  • 13. Workshop & Assignment Develop a web blog with comments with mocked user data *Hint - Getting a request from HTML form using $request from post route