1. commands
The commandsdirectorycontainsanycustom artisancommandline interface commandsthatare
requiredbyyourapplication.Yousee the ArtisanCLInotonlyprovidesdefaultfunctionalitytohelp
youbuildyourproject,butyou mayalso create customcommandsto do yourbidding.
config
The configurationforboththe frameworkandyourapplicationare keptwithinthisdirectory.
Laravel’sconfigurationexistsasa setof PHPfilescontainingkey-valuearrays.Thisdirectory
will alsocontainsubdirectorieswhichallow fordifferentconfigurationstobe loadedindifferent
environments.
controllers
As the name suggests,thisdirectorywillholdyourcontrollers.Controllerscanbe usedtoprovide
applicationlogic,andtoglue the separate partsof your applicationtogether.Thisdirectoryhasbeen
addedto the defaultcomposer.jsonasaclassmapautoloadlocationforyourconvenience.
database
Shouldyouchoose touse a database as a methodof longterm storage,thenthisdirectorywill be
usedto holdthe filesthatwill create yourdatabase schema,andmethodsforseedingitwithsample
data. The defaultSQLite database isalsolocatedinthisdirectory.
lang
The lang directorycontainsPHPfileswith arraysof stringsthatcan be usedto provide localisation
supportto yourapplication.Subfoldersnamedbyregionallow forstringfilestoexistformultiple
languages.
models
The modelsdirectorywill containyourmodels.Surprised?Modelsare usedto representyour
businessmodel,orprovide interactionwithstorage.Confused?Don’tworry.We will covermodels
indetail ina laterchapter.Knowthat a User model hasbeenprovidedforyoutoenable application
2. authentication‘outof the box’.Like the controllersdirectory,thishasbeenaddedtothe classmap
autoloadsectionof the defaultcomposer.json.
start
Where the bootstrapdirectorycontainsthe startupproceduresthatbelongtothe framework,
the start directorycontainsstartupproceduresthatbelongtoyourapplication.Asalways,some
sensible defaultshave beenprovidedforyou.
storage
WhenLaravel needstowrite anythingtodisk,itdoesso withinthe storage directory.Forthis
reasonyourwebservermustbe able towrite to thislocation.
tests
The testsdirectorywill containall of the unitandacceptance testsfor yourapplication.The default
PHP UnitconfigurationthathasbeenincludedwithLaravel,willlookfortestswithinthisdirectory
by default.
views
The viewsdirectoryisusedtocontainthe visual templatesforyourapplication.A defaulthello
viewhasbeenprovidedforyourconvenience.
filters.php
The filters.phpfile isusedtocontainthe route filtersforyourapplication.Youwill learnmore
aboutfiltersina future chapter.
routes.php
The routesfile containsall of the routesforyour application.Youdon’tknow whatroutesare?Well,
let’snotwaste anymore time then.Onwardstothe nextchapter!
3. 1 ROUTING.
1. DASARROUTING
Ex
: http://koreknil.com/function/parameter
Dalamcontoh ini,kitamenggunakan protokol http (digunakan olehkebanyakanbrowser
web) untukmengakses Laravel.
BerikutcontohcontohmendasartentangRoutes(route.php) :
Pada Routes::tersediabeberapametode:
a. Basic Routes:
Url addres: http://koreknil.com/my/page(Routesdi laravel hampirsamafungsinyaseperti
pada controllerdi CI)
b. Basic Routes dalamString:
c. Basic RoutesDenganUri :
4. Url addres: http://koreknil.com/first/page,../seceond/page,../third/page
d. Basic Routesdengansitushierarki
Implementasi padaroutes(contoh) :
2. RoutesDenganParameter
a. Menggunakanparameterpadauri
URL address: http://koreknil.com/gis/hotel(memasukkanuri padaurl address)
Hasil : GIS in the HOTEL category (implementasi padakoreknil)
b. Menggunakanparameterpadauri denganoptional.
6. 2. ViewdengandataARRAY
Pada html file :
Gunakan“/great” pada URL addressmakahasilnyaakan“I wishI were a great
squirrel!”.
3 Redirect.
1. Contohredirect
2. Contohuntuklogin:
Hanya contohkecil,kedepanyaakanadacara yang lebih baik
7. 4 Custom Response
Disini kitabisamembuatresponsehttpkitasendiri dalamsetiapprosesyangadadalamkonten
website kita.Tidakbanyakteori langsungkitacome on :
1. Simple customresponse
“200” mempunyai arti oke.Responsstandaruntuk permintaan HTTP sukses
2. Simple responsedengansetnilaiheader (EX)
Disini kitabisamensetnilai dari headeryangakanditampilkan
3. Simple responsedengansetnilaiheader
4. Simple responsedengansetttl
5. Simple responsedenganjson
Be shownlike thismen:
6. Simple responsedownload