By Gus Purwania
About me
• Ida Bagus Gede Purwania, S.TI.
• Programming since 9 years
• Graduated Information Technology at Udayana University
• Currently working as Co-Founder & Web Back End Developer at
PT. Digital Artisans Indonesia, so I can be up to date with the latest
technologies
https://digitalartisans.id/
Gus Purwania
https://github.com/guspurwania
We will learn today …
• Framework Trends
• What is Laravel? Features & Requirements
• Install Laravel 5 with Composer
• Files structure
• What is artisan and how does it save us time?
• Routing and route types
What is Laravel?
• Laravel is MVC PHP framework created by Taylor Otwell in 2011
• Free open-source license with many contributors worldwide
• One of the best frameworks together with Symfony, CodeIgniter, Yii
• Has powerful features, saving us time
• Uses Symfony packages
• Lets see some statistics
Google Trends (2012 – 2017)
PHP Framework Popularity at Work –
SitePoint 2015
Features
• Eloquent ORM (object-relational mapping) – implements ActiveRecord
• Query builder – helps you to build secured SQL queries
• Restful controllers – provides a way for separating the different HTTP requests (GET, POST,
DELETE, etc.)
• Blade template engine – combines templates with a data model to produce views
• Migrations – version control system for database, update your database easier
• Database seeding – provides a way to populate database tables with test data used for testing
• Pagination – easy to use advanced pagination functionalities
• Forms security – provides CSRF token middleware, protecting all the forms
Must have packages
• Laravel debugbar - https://github.com/barryvdh/laravel-debugbar
Great for debugging on local environment. Shows all the views, requests, exceptions loaded for the
current page.
• LaravelCollective – Forms & HTML - https://laravelcollective.com/docs/master/html
Perfect for generating forms, inputs, script tags and style tags
• Laravel IDE Helper - https://github.com/barryvdh/laravel-ide-helper
The package helps your IDE with autocomplete and autosuggest methods, views, functions and
more.
Server Requirement
• PHP >= 7.1.3
• OpenSSL PHP Extension
• PDO PHP Extension
• Mbstring PHP Extension
• Tokenizer PHP Extension
• XML PHP Extension
• Ctype PHP Extension
• JSON PHP Extension
Let’s install Laravel
• Laravel uses Composer to manage its
dependencies
• Composer is dependency management tool for
PHP, like a library full of books
• NOT like Yum or apt
• Per project tool (vendor folder), not per system
• Install by using the command:
composer global require “laravel/installer”
laravel new blog
The structure
app/Http folder contains the Controllers,
Middlewares and Kernel file
All the models should be located in app/Models
folder
The service providers that are bootstrapping
functions in our app are located in
app/Providers folder
All the config files are located in app/config
folder
Database folder contains the
migrations and seeds
The public folder is the actual folder you are
opening on the web server.
All JS / CSS / Images / Uploads are located there.
The resources folder contains all the
translations, views and assets (SASS, LESS, JS)
that are compiled into public folder
The routes folder contains all the routes for the
project
All the logs / cache files are located in storage
folder
The vendor folder contains all the composer
packages (dependencies)
Artisan !
• Artisan is command-line interface for
Laravel
• Commands that are saving time
• Generating files with artisan is
recommended
• Run php artisan list in the console
Routing
• The best and easy routing system I’ve seen
• Routing per middleware / prefix or
namespace
• Routing per request method (GET, POST,
DELETE, etc.)
• ALWAYS name your route !
• Be careful with the routing order !
• Let’s see routing examples
Thank You! Questions?