SlideShare a Scribd company logo
10
Most read
18
Most read
19
Most read
INTRODUCTION TO LARAVEL
By
Awulonu Obinna
ABOUT THE SPEAKER
Developer and Web Admin @ Headquarters Nigerian Airforce
Twitter – https://www.twitter.com/awulonu_obinna
Facebook – https://www.facebook.com/awulonuobinna
GitHub – https://www.github.com/obinosteve
#phpenthusiast #laravelevangelist
What is Laravel?
Laravel is a free, open-sourcePHP web framework, used for
development of web applications following the model-view
controller (MVC) architectural pattern.
What is a Framework?
A framework is a piece of code which dictates the architecture your
project will follow. Once you choose a framework to work with, you
have to follow the framework's code and design methodologies. The
framework will provide you with hooks and callbacks, so that
you build on it - it will then call your plugged-in code whenever it
wishes, a phenomenon called Inversion of Control.
What is mvc?
The Model-View-Controller (MVC) is an architectural pattern
that provides a reusable solution to resolve common problems
that occurs while developing a Web application. It separates an
application into three main logical components: the model, view
and controller.
Model:
The model is responsible for managing the data of the application. It
responds to the request from the view and it also responds to
instructions from the controller to update itself.
View:
The View component is used for all the UI logic of the application.
The view includes all the UI components such as text boxes,
dropdowns, buttons, etc. that the final user interacts with.
Controller:
Controller is responsible for controlling the application logic and acts as the
coordinator between the View and the Model. The Controller receives input from
users via the View, then process the user's data with the help of Model and passing
the results back to the View.
Benefits of the MVC Pattern
 Separation of concerns: Enables you to ensure that various application concerns
into different and independent software components. Thus, it allows you to work on a
single component independently.
 Simplified testing and maintenance: Enables you to test each component
independently.
 Extensibility: Enables the model to include a set of independent components that you
can easily modify or replace based on the application requirement.
 Faster development process
 Ability to provide multiple views
 SEO friendly Development platform: It is very easy to develop SEO-friendly URLs to
generate more visits from a specific application.
Architecture of a Laravel Application
Did we miss anything? Routing?
What is Routing in Laravel ?
Routing
Routing defines how the application will process and respond to
incoming HTTP request. You can use URLs that properly describes the
controller action to which the request needs to be routed.
Routing enables use of URLs that are descriptive of the user actions
and are more easily understood by the users.
e.g Instead of http://myapplication/Users.php?id=1
we can
http://myapplication/Users/1
Letz Get Started
Environment Setup
 Laravel Homestead https://laravel.com/docs/5.5/homestead
 Laragon https://laragon.org/
 Method 3:
 Wamp server: http://www.wampserver.com/en/
 Composer: https://getcomposer.org/download/
 Nodejs: https://nodejs.org/en/
 Npm: Installed on your computer when you install Node.js
Create new Laravel Project
 From your command prompt or terminal or git bash, run:
composer create-project --prefer-dist laravel/laravel projectname
 Run your first laravel application:
php artisan serve
CONGRATULATIONS
You have successfully ran your first laravel app
Laravel Directory Structure
 App Directory: Contains the core code of your application. A variety of
other directories will be generated inside the app directory as you use
the make Artisan commands to generate classes.
 Bootstrap Directory: Contains the app.php file which bootstraps the
framework.
 Config Directory: Contains all of your application's configuration files.
 Database Directory: Contains your database migration and seeds.
 Public Directory: Contains the index.php file, which is the entry point for
all requests entering your application and configures autoloading. This
directory also houses your assets such as images, JavaScript, and CSS.
 Resources Directory: Contains your views as well as your raw, un-compiled
assets such as LESS, SASS, or JavaScript.
 Routes Directory: Contains all of the route definitions for your application.
 Storage Directory: Contains your compiled Blade templates, file based
sessions, file caches, and other files generated by the framework.
 Tests Directory: Contains your automated tests.
 Vendor Directory: Contains your composer dependencies.
Default Laravel Technologies
The following technologies are included by default:
 Jquery: A cross-platform Js library designed to simplify the client-side scripting of
HTML.
 Bootstrap: Bootstrap is the most popular HTML, CSS, and Js framework for
developing responsive, mobile-first web sites
 Axios: A Js library used to make http requests from node.js or XMLHttpRequests
from the browser and it supports the Promise API that is native to JS ES6.
 Vue: Popular Js framework for building user interfaces.
 Lodash: A Js library that helps programmers write more concise and easier to
maintain Js.
 Cross-env: Run scripts that set and use environment variables across platforms
Letz Code
Laravel App Development Steps
 Verify that inside the .env file, APP_KEY is set and APP_DEBUG is set
to true
 Set the DB_CONNECTION, DB_HOST, DB_PORT, DB_DATABASE,
DB_USERNAME and DB_PASSWORD correctly.
 Create and migrate your database migration
 Create the model
 Create the controller
 Create the route inside your route/web.php file
 Create the View
Say Hi to Eloquent ORM!
Eloquent ORM allow developers use Active Record pattern.
Active Record pattern is a technique of wrapping database into objects.
By using this technique, developers can present data stored in a
database table as class, and row as an object. Each database
table has a corresponding “Model” which is used to interact with that
table. It helps to make our codes look cleaner and readable. We can
use Eloquent ORM to create, edit, manipulate, query and delete entries
easily
Eloquent Model Methods
‱ Model::create(array('key' => 'value'));
‱ Model::update(array('key' => 'value'));
‱ Model::delete(1);
‱ Model::all();
‱ Model::find(1);
‱ // Trigger an exception
‱ Model::findOrFail(1);
‱ Model::where('foo', '=', 'bar')->get();
‱ Model::where('foo', '=', 'bar')->first();
‱ // Exception
‱ Model::where('foo', '=', 'bar')->firstOrFail();
‱ Model::where('foo', '=', 'bar')->count();
‱ Model::where('foo', '=', 'bar')->delete();
‱ Model::whereRaw('foo = bar and cars = 2', array(20))->get();
‱ Model::on('connection-name')->find(1);
‱ Model::with('relation')->get();
‱ Model::all()->take(10);
‱ Model::all()->skip(10)
Understanding Controllers
 Index: Display a listing of the resource.
 Create: Show the form for creating a new resource.
 Store: Store a newly created resource in the storage.
 Show: Display the specified resource.
 Edit: Show the form for editing the specified resource.
 Update: Update the specified resource in storage.
 Destroy: Delete the specified resource from storage.
Understanding Route Parameters
‱ Route::get('foo', function(){});
‱ Route::get('foo', 'ControllerName@function');
‱ Route::get('foo/{bar}', function($bar){});
‱ Route::get('foo/{bar}', 'ControllerName@function');
‱ Route::post('foo', function(){});
‱ Route::put('foo', function(){});
‱ Route::delete('foo', function(){});
RESTFUL ACTIONS
‱ Route::resource('foo', 'FooController');
QUESTIONS
??
THANKS

More Related Content

PDF
Web Development with Laravel 5
PPTX
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
PPTX
Laravel
PPTX
Laravel introduction
PPTX
Laravel Tutorial PPT
PDF
Laravel presentation
PPTX
Introduction to laravel framework
PDF
Laravel Introduction
Web Development with Laravel 5
Laravel development (Laravel History, Environment Setup & Laravel Installatio...
Laravel
Laravel introduction
Laravel Tutorial PPT
Laravel presentation
Introduction to laravel framework
Laravel Introduction

What's hot (20)

PDF
Laravel - The PHP Framework for Web Artisans
PPTX
Laravel ppt
PPTX
Laravel
PPTX
laravel.pptx
PDF
Why Laravel?
PPTX
Lecture 2_ Intro to laravel.pptx
PPTX
What-is-Laravel-23-August-2017.pptx
PDF
REST API and CRUD
PDF
JPA and Hibernate
PDF
A Basic Django Introduction
PDF
Model View Controller (MVC)
PPTX
Introduction to Node.js
PDF
Spring Boot
PDF
Spring MVC Framework
PPTX
Understanding REST APIs in 5 Simple Steps
PPTX
Rest API
PPTX
Spring Framework
 
PPTX
PPTX
Oracle application express ppt
PDF
Quick flask an intro to flask
 
Laravel - The PHP Framework for Web Artisans
Laravel ppt
Laravel
laravel.pptx
Why Laravel?
Lecture 2_ Intro to laravel.pptx
What-is-Laravel-23-August-2017.pptx
REST API and CRUD
JPA and Hibernate
A Basic Django Introduction
Model View Controller (MVC)
Introduction to Node.js
Spring Boot
Spring MVC Framework
Understanding REST APIs in 5 Simple Steps
Rest API
Spring Framework
 
Oracle application express ppt
Quick flask an intro to flask
 
Ad

Similar to Laravel overview (20)

PDF
Laravel Web Development: A Comprehensive Guide
PDF
Memphis php 01 22-13 - laravel basics
PDF
Laravel Structure: Key Aspects of Application Architecture Explained
PDF
Laravel 4 presentation
PDF
Lecture11_LaravelGetStarted_SPring2023.pdf
PDF
Step by Step Guide to Build the Laravel Web App.pdf
PPTX
Introduction_to_Laravel_Background DOCUMENTATION.pptx
PPTX
Introduction_to_Laravel_Simple DUCUMENTATION.pptx
PPTX
What-is-Laravel and introduciton to Laravel
PDF
Object Oriented Programming with Laravel - Session 2
ODP
Laravel 5.3 - Web Development Php framework
PPT
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
PPTX
Getting started with laravel
PPTX
Laravel 5
PDF
Laravel (8) php_framework_handbook__start_from_zer_18604872_(z-lib.org)
PPTX
Laravel : A Fastest Growing Kid
PPT
Web service with Laravel
PDF
Laravel tutorial
ODP
Projects In Laravel : Learn Laravel Building 10 Projects
PDF
laravel-interview-questions.pdf
Laravel Web Development: A Comprehensive Guide
Memphis php 01 22-13 - laravel basics
Laravel Structure: Key Aspects of Application Architecture Explained
Laravel 4 presentation
Lecture11_LaravelGetStarted_SPring2023.pdf
Step by Step Guide to Build the Laravel Web App.pdf
Introduction_to_Laravel_Background DOCUMENTATION.pptx
Introduction_to_Laravel_Simple DUCUMENTATION.pptx
What-is-Laravel and introduciton to Laravel
Object Oriented Programming with Laravel - Session 2
Laravel 5.3 - Web Development Php framework
Laravel Starter Kit | Laravel Admin Template-ChandraAdmin
Getting started with laravel
Laravel 5
Laravel (8) php_framework_handbook__start_from_zer_18604872_(z-lib.org)
Laravel : A Fastest Growing Kid
Web service with Laravel
Laravel tutorial
Projects In Laravel : Learn Laravel Building 10 Projects
laravel-interview-questions.pdf
Ad

Recently uploaded (20)

PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
AI in Product Development-omnex systems
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PPT
Introduction Database Management System for Course Database
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
System and Network Administraation Chapter 3
PDF
medical staffing services at VALiNTRY
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
How Creative Agencies Leverage Project Management Software.pdf
AI in Product Development-omnex systems
Odoo Companies in India – Driving Business Transformation.pdf
VVF-Customer-Presentation2025-Ver1.9.pptx
Odoo POS Development Services by CandidRoot Solutions
Wondershare Filmora 15 Crack With Activation Key [2025
How to Choose the Right IT Partner for Your Business in Malaysia
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
How to Migrate SBCGlobal Email to Yahoo Easily
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Introduction Database Management System for Course Database
ISO 45001 Occupational Health and Safety Management System
System and Network Administraation Chapter 3
medical staffing services at VALiNTRY
CHAPTER 2 - PM Management and IT Context
Softaken Excel to vCard Converter Software.pdf
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx

Laravel overview

  • 2. ABOUT THE SPEAKER Developer and Web Admin @ Headquarters Nigerian Airforce Twitter – https://www.twitter.com/awulonu_obinna Facebook – https://www.facebook.com/awulonuobinna GitHub – https://www.github.com/obinosteve #phpenthusiast #laravelevangelist
  • 3. What is Laravel? Laravel is a free, open-sourcePHP web framework, used for development of web applications following the model-view controller (MVC) architectural pattern.
  • 4. What is a Framework? A framework is a piece of code which dictates the architecture your project will follow. Once you choose a framework to work with, you have to follow the framework's code and design methodologies. The framework will provide you with hooks and callbacks, so that you build on it - it will then call your plugged-in code whenever it wishes, a phenomenon called Inversion of Control.
  • 5. What is mvc? The Model-View-Controller (MVC) is an architectural pattern that provides a reusable solution to resolve common problems that occurs while developing a Web application. It separates an application into three main logical components: the model, view and controller.
  • 6. Model: The model is responsible for managing the data of the application. It responds to the request from the view and it also responds to instructions from the controller to update itself. View: The View component is used for all the UI logic of the application. The view includes all the UI components such as text boxes, dropdowns, buttons, etc. that the final user interacts with. Controller: Controller is responsible for controlling the application logic and acts as the coordinator between the View and the Model. The Controller receives input from users via the View, then process the user's data with the help of Model and passing the results back to the View.
  • 7. Benefits of the MVC Pattern  Separation of concerns: Enables you to ensure that various application concerns into different and independent software components. Thus, it allows you to work on a single component independently.  Simplified testing and maintenance: Enables you to test each component independently.  Extensibility: Enables the model to include a set of independent components that you can easily modify or replace based on the application requirement.  Faster development process  Ability to provide multiple views  SEO friendly Development platform: It is very easy to develop SEO-friendly URLs to generate more visits from a specific application.
  • 8. Architecture of a Laravel Application
  • 9. Did we miss anything? Routing? What is Routing in Laravel ?
  • 10. Routing Routing defines how the application will process and respond to incoming HTTP request. You can use URLs that properly describes the controller action to which the request needs to be routed. Routing enables use of URLs that are descriptive of the user actions and are more easily understood by the users. e.g Instead of http://myapplication/Users.php?id=1 we can http://myapplication/Users/1
  • 12. Environment Setup  Laravel Homestead https://laravel.com/docs/5.5/homestead  Laragon https://laragon.org/  Method 3:  Wamp server: http://www.wampserver.com/en/  Composer: https://getcomposer.org/download/  Nodejs: https://nodejs.org/en/  Npm: Installed on your computer when you install Node.js
  • 13. Create new Laravel Project  From your command prompt or terminal or git bash, run: composer create-project --prefer-dist laravel/laravel projectname  Run your first laravel application: php artisan serve CONGRATULATIONS You have successfully ran your first laravel app
  • 15.  App Directory: Contains the core code of your application. A variety of other directories will be generated inside the app directory as you use the make Artisan commands to generate classes.  Bootstrap Directory: Contains the app.php file which bootstraps the framework.  Config Directory: Contains all of your application's configuration files.  Database Directory: Contains your database migration and seeds.  Public Directory: Contains the index.php file, which is the entry point for all requests entering your application and configures autoloading. This directory also houses your assets such as images, JavaScript, and CSS.  Resources Directory: Contains your views as well as your raw, un-compiled assets such as LESS, SASS, or JavaScript.  Routes Directory: Contains all of the route definitions for your application.  Storage Directory: Contains your compiled Blade templates, file based sessions, file caches, and other files generated by the framework.  Tests Directory: Contains your automated tests.  Vendor Directory: Contains your composer dependencies.
  • 16. Default Laravel Technologies The following technologies are included by default:  Jquery: A cross-platform Js library designed to simplify the client-side scripting of HTML.  Bootstrap: Bootstrap is the most popular HTML, CSS, and Js framework for developing responsive, mobile-first web sites  Axios: A Js library used to make http requests from node.js or XMLHttpRequests from the browser and it supports the Promise API that is native to JS ES6.  Vue: Popular Js framework for building user interfaces.  Lodash: A Js library that helps programmers write more concise and easier to maintain Js.  Cross-env: Run scripts that set and use environment variables across platforms
  • 18. Laravel App Development Steps  Verify that inside the .env file, APP_KEY is set and APP_DEBUG is set to true  Set the DB_CONNECTION, DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME and DB_PASSWORD correctly.  Create and migrate your database migration  Create the model  Create the controller  Create the route inside your route/web.php file  Create the View
  • 19. Say Hi to Eloquent ORM! Eloquent ORM allow developers use Active Record pattern. Active Record pattern is a technique of wrapping database into objects. By using this technique, developers can present data stored in a database table as class, and row as an object. Each database table has a corresponding “Model” which is used to interact with that table. It helps to make our codes look cleaner and readable. We can use Eloquent ORM to create, edit, manipulate, query and delete entries easily
  • 20. Eloquent Model Methods ‱ Model::create(array('key' => 'value')); ‱ Model::update(array('key' => 'value')); ‱ Model::delete(1); ‱ Model::all(); ‱ Model::find(1); ‱ // Trigger an exception ‱ Model::findOrFail(1); ‱ Model::where('foo', '=', 'bar')->get(); ‱ Model::where('foo', '=', 'bar')->first(); ‱ // Exception ‱ Model::where('foo', '=', 'bar')->firstOrFail(); ‱ Model::where('foo', '=', 'bar')->count(); ‱ Model::where('foo', '=', 'bar')->delete(); ‱ Model::whereRaw('foo = bar and cars = 2', array(20))->get(); ‱ Model::on('connection-name')->find(1); ‱ Model::with('relation')->get(); ‱ Model::all()->take(10); ‱ Model::all()->skip(10)
  • 21. Understanding Controllers  Index: Display a listing of the resource.  Create: Show the form for creating a new resource.  Store: Store a newly created resource in the storage.  Show: Display the specified resource.  Edit: Show the form for editing the specified resource.  Update: Update the specified resource in storage.  Destroy: Delete the specified resource from storage.
  • 22. Understanding Route Parameters ‱ Route::get('foo', function(){}); ‱ Route::get('foo', 'ControllerName@function'); ‱ Route::get('foo/{bar}', function($bar){}); ‱ Route::get('foo/{bar}', 'ControllerName@function'); ‱ Route::post('foo', function(){}); ‱ Route::put('foo', function(){}); ‱ Route::delete('foo', function(){}); RESTFUL ACTIONS ‱ Route::resource('foo', 'FooController');