SlideShare a Scribd company logo
1 of 17
Download to read offline
Boutique product development company
It is amazing what you can accomplish when you have a client-centric team to deliver outstanding products.
Web Services with Laravel
Boutique product development company
Abuzer Firdousi | SE

It is amazing what you can accomplish when you have a client-centric team to deliver outstanding products.
Web Services with Laravel

Content:

•
•
•
•
•
•
•
•
•
•
•
•
•

Laravel Philosophy
Requirement
Installation
Basic Routing

Requests & Input
Request Lifecycle
Controller
Controller Filters
RESTful Controllers
Database Model using Eloquent ORM
Creating A Migration
Code Example
Questions

Abuzer Firdousi
Laravel Philosophy
Laravel is a web application framework with expressive, elegant syntax. We believe development
must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of
development by easing common tas

• ROR
• ASP.NET MVC
• Sinatra (Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort)
Laravel is accessible, yet powerful, providing powerful tools needed for large, robust applications.

Laravel, the elegant PHP framework for web artisans
Abuzer Firdousi
Server Requirements
The Laravel framework has a few system requirements:
• PHP >= 5.3.7
• MCrypt PHP Extension

As of PHP 5.5, some OS distributions may require you to manually install the PHP JSON extension.
When using Ubuntu, this can be done via apt-get install php5-json.
MCrypt:
1. aptitude install php5-mcrypt
2. echo extension=php_mcrypt.so >> /etc/php5/apache2/php.ini
3. /etc/init.d/apache2 restart

Abuzer Firdousi
Installation
Laravel utilizes Composer to manage its dependencies. First, download a copy of the composer.phar.
Via Composer Create-Project
You may install Laravel by issuing the Composer create-project command in your terminal:
composer create-project laravel/laravel --prefer-dist
Via Download
Once Composer is installed, download the latest version of the Laravel framework and extract its
contents into a directory on your server. Next, in the root of your Laravel application, run the php
composer.phar install (or composer install) command to install all of the framework's
dependencies. This process requires Git to be installed on the server to successfully complete the
installation.
If you want to update the Laravel framework, you may issue the php composer.phar update
command.
Laravel provides a server, and we can run the server with “php artisan* serve”

* command-line interface, a powerful Symfony Console component
Abuzer Firdousi
Basic Routing
Most of the routes for your application will be defined in the app/routes.php file. The simplest
Laravel routes consist of a URI and a Closure callback.

Basic GET Route:

Route::get('/', function()
{
return 'Hello World';
});

Basic POST Route:
Route::post('foo/bar', function()
{
return 'Hello World';
});

Abuzer Firdousi
Route Parameters
Route Parameters:
Route::get('user/{id}', function($id)
{
return 'User '.$id;
});
Optional Route Parameters:
Route::get('user/{name?}', function($name = null)
{

return $name;
});
Throwing 404 Errors:
There are two ways to manually trigger a 404 error from a route. First, you may use the App::abort
method:

App::abort(404);

Abuzer Firdousi
Requests & Input
Retrieving An Input Value

$name = Input::get('name');

Retrieving A Default Value If The Input Value Is Absent

$name = Input::get('name', Abuzer);

Getting All Input For The Request

$input = Input::all();

Abuzer Firdousi
Request Life Cycle
The Laravel request lifecycle is fairly simple. A request enters your application and is dispatched to
the appropriate route or controller. The response from that route is then sent back to the browser
and displayed on the screen. Sometimes you may wish to do some processing before or after your
routes are actually called. There are several opportunities to do this, two of which are "start" files
and application events.

Abuzer Firdousi
Controllers
Instead of defining all of your route-level logic in a single routes.php file, you may wish to organize
this behavior using Controller classes. Controllers can group related route logic into a class, as
well as take advantage of more advanced framework features such as automatic dependency
injection.

Controllers are typically stored in the app/controllers directory, and this directory is registered in
the class map option of your composer.json file by default.
Here is an example of a basic controller class:
class UserController extends BaseController {
/**

* Show the profile for the given user.

*/

public function showProfile($id)
{
$user = User::find($id); //
return Response::json( array('user' => $user) );

}
}
Abuzer Firdousi
Controllers and Routes
All controllers should extend the BaseController class. The BaseController is also stored in the
app/controllers directory, and may be used as a place to put shared controller logic. The
BaseController extends the framework's Controller class. Now, We can route to this controller
action like so:

Route::get('user/{id}', 'UserController@showProfile');
If you choose to nest or organize your controller using PHP namespaces, simply use the fully
qualified class name when defining the route:
Route::get('foo', 'NamespaceFooController@method');

You may also specify names on controller routes:
Route::get('foo', array('uses' => 'FooController@method', 'as' => 'name'));

Abuzer Firdousi
Controller Filters
Filters may be specified on controller routes similar to "regular" routes: ( Kind of Request
INTERCEPTOR)
Route::get('profile', array('before' => 'auth',
'uses' => 'UserController@showProfile'));
However, you may also specify filters from within your controller:
class UserController extends BaseController {
/**

* Instantiate a new UserController instance.

*/

public function __construct()
{
$this->beforeFilter('auth', array('except' => 'getLogin'));
$this->afterFilter('log', array('only' =>
array('fooAction', 'barAction')));
}
}
Abuzer Firdousi
RESTful Controllers
Laravel allows you to easily define a single route to handle every action in a controller using
simple, REST naming conventions. First, define the route using the Route::controller method:
Defining A RESTful Controller

Route::controller('users', 'UserController');
The controller method accepts two arguments. The first is the base URI the controller handles,
while the second is the class name of the controller. Next, just add methods to your controller,
prefixed with the HTTP verb they respond to:
class UserController extends BaseController {
public function getIndex()
{
// }
public function postIndex()
{
// }
public function putIndex()
{
// }
public function deleteIndex()
{
// }
}
Abuzer Firdousi
Eloquent ORM
The Eloquent ORM included with Laravel provides a beautiful, simple ActiveRecord
implementation for working with your database. Each database table has a corresponding "Model"
which is used to interact with that table.
Before getting started, be sure to configure a database connection in app/config/database.php.
class User extends Eloquent {
protected $table = 'my_users';
}
Retrieving All Models
$users = User::all();

Retrieving A Record By Primary Key
$user = User::find(1);
Querying Using Eloquent Models
$users = User::where('votes', '>', 100)->take(10)->get();
foreach ($users as $user)
var_dump($user->name);

Abuzer Firdousi
Example
Repo:
https://bitbucket.org/abuzerfirdousi/dt
Route:
https://bitbucket.org/abuzerfirdousi/dt/src/2375a67ef4e9f7fedbc1
74842a339d50f9e4d5ae/app/routes.php?at=master
Controller:
https://bitbucket.org/abuzerfirdousi/dt/src/2375a67ef4e9f7fedbc1
74842a339d50f9e4d5ae/app/controllers/TodoController.php?at=
master
Model:
https://bitbucket.org/abuzerfirdousi/dt/src/2375a67ef4e9f7fedbc1
74842a339d50f9e4d5ae/app/models/Todo.php?at=master

Abuzer Firdousi
Questions ?

Abuzer Firdousi

More Related Content

What's hot

2019 DevSecOps Reference Architectures
2019 DevSecOps Reference Architectures2019 DevSecOps Reference Architectures
2019 DevSecOps Reference ArchitecturesSonatype
 
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...Edureka!
 
Front end web development
Front end web developmentFront end web development
Front end web developmentviveksewa
 
PHP Summer Training Presentation
PHP Summer Training PresentationPHP Summer Training Presentation
PHP Summer Training PresentationNitesh Sharma
 
Roles and Responsibilities of a DevOps Engineer
Roles and Responsibilities of a DevOps EngineerRoles and Responsibilities of a DevOps Engineer
Roles and Responsibilities of a DevOps EngineerZaranTech LLC
 
Cloud Native Camel Design Patterns
Cloud Native Camel Design PatternsCloud Native Camel Design Patterns
Cloud Native Camel Design PatternsBilgin Ibryam
 
Building a CICD pipeline for deploying to containers
Building a CICD pipeline for deploying to containersBuilding a CICD pipeline for deploying to containers
Building a CICD pipeline for deploying to containersAmazon Web Services
 
Microsoft Azure - Introduction to microsoft's public cloud
Microsoft Azure - Introduction to microsoft's public cloudMicrosoft Azure - Introduction to microsoft's public cloud
Microsoft Azure - Introduction to microsoft's public cloudAtanas Gergiminov
 
Microservices with Docker
Microservices with Docker Microservices with Docker
Microservices with Docker Venkata Naga Ravi
 
01 la programmation batch - les debuts
01   la programmation batch - les debuts01   la programmation batch - les debuts
01 la programmation batch - les debutsWenceslas Dima
 
Docker containers
Docker containersDocker containers
Docker containersPau LĂłpez
 
Apache Groovy: the language and the ecosystem
Apache Groovy: the language and the ecosystemApache Groovy: the language and the ecosystem
Apache Groovy: the language and the ecosystemKostas Saidis
 
Blueprinting DevOps for Digital Transformation_v4
Blueprinting DevOps for Digital Transformation_v4Blueprinting DevOps for Digital Transformation_v4
Blueprinting DevOps for Digital Transformation_v4Aswin Kumar
 
Docker Swarm 0.2.0
Docker Swarm 0.2.0Docker Swarm 0.2.0
Docker Swarm 0.2.0Docker, Inc.
 
Micro Front-End & Microservices - Plansoft
Micro Front-End & Microservices - PlansoftMicro Front-End & Microservices - Plansoft
Micro Front-End & Microservices - PlansoftMiki Lombardi
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to MicroservicesAmazon Web Services
 
DevOps at Amazon: A Look at Our Tools and Processes
DevOps at Amazon: A Look at Our Tools and ProcessesDevOps at Amazon: A Look at Our Tools and Processes
DevOps at Amazon: A Look at Our Tools and ProcessesAmazon Web Services
 

What's hot (20)

2019 DevSecOps Reference Architectures
2019 DevSecOps Reference Architectures2019 DevSecOps Reference Architectures
2019 DevSecOps Reference Architectures
 
DevOps for beginners
DevOps for beginnersDevOps for beginners
DevOps for beginners
 
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
Microservice Architecture | Microservices Tutorial for Beginners | Microservi...
 
Front end web development
Front end web developmentFront end web development
Front end web development
 
PHP Summer Training Presentation
PHP Summer Training PresentationPHP Summer Training Presentation
PHP Summer Training Presentation
 
Introduction to DevSecOps
Introduction to DevSecOpsIntroduction to DevSecOps
Introduction to DevSecOps
 
Roles and Responsibilities of a DevOps Engineer
Roles and Responsibilities of a DevOps EngineerRoles and Responsibilities of a DevOps Engineer
Roles and Responsibilities of a DevOps Engineer
 
Cloud Native Camel Design Patterns
Cloud Native Camel Design PatternsCloud Native Camel Design Patterns
Cloud Native Camel Design Patterns
 
Building a CICD pipeline for deploying to containers
Building a CICD pipeline for deploying to containersBuilding a CICD pipeline for deploying to containers
Building a CICD pipeline for deploying to containers
 
PHP Project PPT
PHP Project PPTPHP Project PPT
PHP Project PPT
 
Microsoft Azure - Introduction to microsoft's public cloud
Microsoft Azure - Introduction to microsoft's public cloudMicrosoft Azure - Introduction to microsoft's public cloud
Microsoft Azure - Introduction to microsoft's public cloud
 
Microservices with Docker
Microservices with Docker Microservices with Docker
Microservices with Docker
 
01 la programmation batch - les debuts
01   la programmation batch - les debuts01   la programmation batch - les debuts
01 la programmation batch - les debuts
 
Docker containers
Docker containersDocker containers
Docker containers
 
Apache Groovy: the language and the ecosystem
Apache Groovy: the language and the ecosystemApache Groovy: the language and the ecosystem
Apache Groovy: the language and the ecosystem
 
Blueprinting DevOps for Digital Transformation_v4
Blueprinting DevOps for Digital Transformation_v4Blueprinting DevOps for Digital Transformation_v4
Blueprinting DevOps for Digital Transformation_v4
 
Docker Swarm 0.2.0
Docker Swarm 0.2.0Docker Swarm 0.2.0
Docker Swarm 0.2.0
 
Micro Front-End & Microservices - Plansoft
Micro Front-End & Microservices - PlansoftMicro Front-End & Microservices - Plansoft
Micro Front-End & Microservices - Plansoft
 
Introduction to Microservices
Introduction to MicroservicesIntroduction to Microservices
Introduction to Microservices
 
DevOps at Amazon: A Look at Our Tools and Processes
DevOps at Amazon: A Look at Our Tools and ProcessesDevOps at Amazon: A Look at Our Tools and Processes
DevOps at Amazon: A Look at Our Tools and Processes
 

Viewers also liked

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
 
Laravel Restful API and AngularJS
Laravel Restful API and AngularJSLaravel Restful API and AngularJS
Laravel Restful API and AngularJSBlake Newman
 
Agile training workshop
Agile training workshopAgile training workshop
Agile training workshopConfiz
 
REST APIs in Laravel 101
REST APIs in Laravel 101REST APIs in Laravel 101
REST APIs in Laravel 101Samantha Geitz
 
Laravel 5 Annotations: RESTful API routing
Laravel 5 Annotations: RESTful API routingLaravel 5 Annotations: RESTful API routing
Laravel 5 Annotations: RESTful API routingChristopher Pecoraro
 
Web service with Laravel
Web service with LaravelWeb service with Laravel
Web service with LaravelAbuzer Firdousi
 
Javascript laravel's friend
Javascript laravel's friendJavascript laravel's friend
Javascript laravel's friendBart Van Den Brande
 
Web Services PHP Tutorial
Web Services PHP TutorialWeb Services PHP Tutorial
Web Services PHP TutorialLorna Mitchell
 
Software Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill SparksSoftware Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill SparksPhill Sparks
 
Java Web Programming [6/9] : MVC
Java Web Programming [6/9] : MVCJava Web Programming [6/9] : MVC
Java Web Programming [6/9] : MVCIMC Institute
 
03 web sherbimet
03 web sherbimet03 web sherbimet
03 web sherbimetKursistat Peje
 
Introduction to Zend Framework web services
Introduction to Zend Framework web servicesIntroduction to Zend Framework web services
Introduction to Zend Framework web servicesMichelangelo van Dam
 
Creating Web Services with Zend Framework - Matthew Turland
Creating Web Services with Zend Framework - Matthew TurlandCreating Web Services with Zend Framework - Matthew Turland
Creating Web Services with Zend Framework - Matthew TurlandMatthew Turland
 
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)Ryan Cuprak
 
Control interno
Control internoControl interno
Control internoeikagale
 
Curso Control Preventivo FEB.2014 - Dr. Miguel Aguilar Serrano
Curso Control Preventivo FEB.2014 - Dr. Miguel Aguilar SerranoCurso Control Preventivo FEB.2014 - Dr. Miguel Aguilar Serrano
Curso Control Preventivo FEB.2014 - Dr. Miguel Aguilar Serranomiguelserrano5851127
 
Asp.net architecture
Asp.net architectureAsp.net architecture
Asp.net architectureIblesoft
 
Web Services Tutorial
Web Services TutorialWeb Services Tutorial
Web Services TutorialLorna Mitchell
 

Viewers also liked (20)

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
 
Laravel Restful API and AngularJS
Laravel Restful API and AngularJSLaravel Restful API and AngularJS
Laravel Restful API and AngularJS
 
Agile training workshop
Agile training workshopAgile training workshop
Agile training workshop
 
REST APIs in Laravel 101
REST APIs in Laravel 101REST APIs in Laravel 101
REST APIs in Laravel 101
 
Laravel 5 Annotations: RESTful API routing
Laravel 5 Annotations: RESTful API routingLaravel 5 Annotations: RESTful API routing
Laravel 5 Annotations: RESTful API routing
 
Web service with Laravel
Web service with LaravelWeb service with Laravel
Web service with Laravel
 
Javascript laravel's friend
Javascript laravel's friendJavascript laravel's friend
Javascript laravel's friend
 
Web Services PHP Tutorial
Web Services PHP TutorialWeb Services PHP Tutorial
Web Services PHP Tutorial
 
Software Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill SparksSoftware Design Patterns in Laravel by Phill Sparks
Software Design Patterns in Laravel by Phill Sparks
 
Java Web Programming [6/9] : MVC
Java Web Programming [6/9] : MVCJava Web Programming [6/9] : MVC
Java Web Programming [6/9] : MVC
 
03 web sherbimet
03 web sherbimet03 web sherbimet
03 web sherbimet
 
Introduction to Zend Framework web services
Introduction to Zend Framework web servicesIntroduction to Zend Framework web services
Introduction to Zend Framework web services
 
Creating Web Services with Zend Framework - Matthew Turland
Creating Web Services with Zend Framework - Matthew TurlandCreating Web Services with Zend Framework - Matthew Turland
Creating Web Services with Zend Framework - Matthew Turland
 
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
Hybrid Mobile Development with Apache Cordova and Java EE 7 (JavaOne 2014)
 
Control interno
Control internoControl interno
Control interno
 
.NET Vs J2EE
.NET Vs J2EE.NET Vs J2EE
.NET Vs J2EE
 
Curso Control Preventivo FEB.2014 - Dr. Miguel Aguilar Serrano
Curso Control Preventivo FEB.2014 - Dr. Miguel Aguilar SerranoCurso Control Preventivo FEB.2014 - Dr. Miguel Aguilar Serrano
Curso Control Preventivo FEB.2014 - Dr. Miguel Aguilar Serrano
 
Asp.net architecture
Asp.net architectureAsp.net architecture
Asp.net architecture
 
Web Services
Web ServicesWeb Services
Web Services
 
Web Services Tutorial
Web Services TutorialWeb Services Tutorial
Web Services Tutorial
 

Similar to Web services with laravel

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
 
Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)Viral Solani
 
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 TutorialAdventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 TutorialJoe Ferguson
 
Getting to know Laravel 5
Getting to know Laravel 5Getting to know Laravel 5
Getting to know Laravel 5Bukhori Aqid
 
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
 
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
 
Web Development with Laravel 5
Web Development with Laravel 5Web Development with Laravel 5
Web Development with Laravel 5Soheil Khodayari
 
Meetup 2022 - APIs with Quarkus.pdf
Meetup 2022 - APIs with Quarkus.pdfMeetup 2022 - APIs with Quarkus.pdf
Meetup 2022 - APIs with Quarkus.pdfLuca Mattia Ferrari
 
Laravel overview
Laravel overviewLaravel overview
Laravel overviewObinna Akunne
 
Laravel presentation
Laravel presentationLaravel presentation
Laravel presentationToufiq Mahmud
 
laravel-interview-questions.pdf
laravel-interview-questions.pdflaravel-interview-questions.pdf
laravel-interview-questions.pdfAnuragMourya8
 
MERN SRTACK WEB DEVELOPMENT NODE JS EXPRESS
MERN SRTACK WEB DEVELOPMENT NODE JS EXPRESSMERN SRTACK WEB DEVELOPMENT NODE JS EXPRESS
MERN SRTACK WEB DEVELOPMENT NODE JS EXPRESSannalakshmi35
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Racksickill
 
Laravel intallation
Laravel intallationLaravel intallation
Laravel intallationsandhya kumari
 
Lecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptxLecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptxSaziaRahman
 

Similar to Web services with laravel (20)

Laravel 5
Laravel 5Laravel 5
Laravel 5
 
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...
 
Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)Introduction to Laravel Framework (5.2)
Introduction to Laravel Framework (5.2)
 
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 TutorialAdventures in Laravel 5 SunshinePHP 2016 Tutorial
Adventures in Laravel 5 SunshinePHP 2016 Tutorial
 
Getting to know Laravel 5
Getting to know Laravel 5Getting to know Laravel 5
Getting to know Laravel 5
 
Laravel
LaravelLaravel
Laravel
 
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
 
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
 
Web Development with Laravel 5
Web Development with Laravel 5Web Development with Laravel 5
Web Development with Laravel 5
 
Meetup 2022 - APIs with Quarkus.pdf
Meetup 2022 - APIs with Quarkus.pdfMeetup 2022 - APIs with Quarkus.pdf
Meetup 2022 - APIs with Quarkus.pdf
 
Laravel overview
Laravel overviewLaravel overview
Laravel overview
 
Laravel presentation
Laravel presentationLaravel presentation
Laravel presentation
 
laravel-interview-questions.pdf
laravel-interview-questions.pdflaravel-interview-questions.pdf
laravel-interview-questions.pdf
 
Laravel 5.3 - Web Development Php framework
Laravel 5.3 - Web Development Php frameworkLaravel 5.3 - Web Development Php framework
Laravel 5.3 - Web Development Php framework
 
Why Laravel?
Why Laravel?Why Laravel?
Why Laravel?
 
MERN SRTACK WEB DEVELOPMENT NODE JS EXPRESS
MERN SRTACK WEB DEVELOPMENT NODE JS EXPRESSMERN SRTACK WEB DEVELOPMENT NODE JS EXPRESS
MERN SRTACK WEB DEVELOPMENT NODE JS EXPRESS
 
Building web framework with Rack
Building web framework with RackBuilding web framework with Rack
Building web framework with Rack
 
Laravel intallation
Laravel intallationLaravel intallation
Laravel intallation
 
Lecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptxLecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptx
 

More from Confiz

DMAIC-Six sigma process Improvement Approach
DMAIC-Six sigma process Improvement ApproachDMAIC-Six sigma process Improvement Approach
DMAIC-Six sigma process Improvement ApproachConfiz
 
What is UFT? HP's unified functional testing.
What is UFT? HP's unified functional testing.What is UFT? HP's unified functional testing.
What is UFT? HP's unified functional testing.Confiz
 
Software testing methods, levels and types
Software testing methods, levels and typesSoftware testing methods, levels and types
Software testing methods, levels and typesConfiz
 
Sqa, test scenarios and test cases
Sqa, test scenarios and test casesSqa, test scenarios and test cases
Sqa, test scenarios and test casesConfiz
 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo designConfiz
 
Entity framework code first
Entity framework code firstEntity framework code first
Entity framework code firstConfiz
 
Security testing presentation
Security testing presentationSecurity testing presentation
Security testing presentationConfiz
 
Ts seo t ech session
Ts   seo t ech sessionTs   seo t ech session
Ts seo t ech sessionConfiz
 
Learning as a creative professional
Learning as a creative professionalLearning as a creative professional
Learning as a creative professionalConfiz
 
Learning as a creative professional
Learning as a creative professionalLearning as a creative professional
Learning as a creative professionalConfiz
 
Ts archiving
Ts   archivingTs   archiving
Ts archivingConfiz
 
Advance text rendering in i os
Advance text rendering in i osAdvance text rendering in i os
Advance text rendering in i osConfiz
 
Ts threading
Ts   threadingTs   threading
Ts threadingConfiz
 
Ts android supporting multiple screen
Ts   android supporting multiple screenTs   android supporting multiple screen
Ts android supporting multiple screenConfiz
 
Ts drupal6 module development v0.2
Ts   drupal6 module development v0.2Ts   drupal6 module development v0.2
Ts drupal6 module development v0.2Confiz
 
Photoshop manners
Photoshop mannersPhotoshop manners
Photoshop mannersConfiz
 
Monkey talk
Monkey talkMonkey talk
Monkey talkConfiz
 
An insight to microsoft platform
An insight to microsoft platformAn insight to microsoft platform
An insight to microsoft platformConfiz
 
Ts branching over the top
Ts   branching over the topTs   branching over the top
Ts branching over the topConfiz
 

More from Confiz (19)

DMAIC-Six sigma process Improvement Approach
DMAIC-Six sigma process Improvement ApproachDMAIC-Six sigma process Improvement Approach
DMAIC-Six sigma process Improvement Approach
 
What is UFT? HP's unified functional testing.
What is UFT? HP's unified functional testing.What is UFT? HP's unified functional testing.
What is UFT? HP's unified functional testing.
 
Software testing methods, levels and types
Software testing methods, levels and typesSoftware testing methods, levels and types
Software testing methods, levels and types
 
Sqa, test scenarios and test cases
Sqa, test scenarios and test casesSqa, test scenarios and test cases
Sqa, test scenarios and test cases
 
Solid principles of oo design
Solid principles of oo designSolid principles of oo design
Solid principles of oo design
 
Entity framework code first
Entity framework code firstEntity framework code first
Entity framework code first
 
Security testing presentation
Security testing presentationSecurity testing presentation
Security testing presentation
 
Ts seo t ech session
Ts   seo t ech sessionTs   seo t ech session
Ts seo t ech session
 
Learning as a creative professional
Learning as a creative professionalLearning as a creative professional
Learning as a creative professional
 
Learning as a creative professional
Learning as a creative professionalLearning as a creative professional
Learning as a creative professional
 
Ts archiving
Ts   archivingTs   archiving
Ts archiving
 
Advance text rendering in i os
Advance text rendering in i osAdvance text rendering in i os
Advance text rendering in i os
 
Ts threading
Ts   threadingTs   threading
Ts threading
 
Ts android supporting multiple screen
Ts   android supporting multiple screenTs   android supporting multiple screen
Ts android supporting multiple screen
 
Ts drupal6 module development v0.2
Ts   drupal6 module development v0.2Ts   drupal6 module development v0.2
Ts drupal6 module development v0.2
 
Photoshop manners
Photoshop mannersPhotoshop manners
Photoshop manners
 
Monkey talk
Monkey talkMonkey talk
Monkey talk
 
An insight to microsoft platform
An insight to microsoft platformAn insight to microsoft platform
An insight to microsoft platform
 
Ts branching over the top
Ts   branching over the topTs   branching over the top
Ts branching over the top
 

Recently uploaded

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Recently uploaded (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

Web services with laravel

  • 1. Boutique product development company It is amazing what you can accomplish when you have a client-centric team to deliver outstanding products.
  • 2. Web Services with Laravel Boutique product development company Abuzer Firdousi | SE It is amazing what you can accomplish when you have a client-centric team to deliver outstanding products.
  • 3. Web Services with Laravel Content: • • • • • • • • • • • • • Laravel Philosophy Requirement Installation Basic Routing Requests & Input Request Lifecycle Controller Controller Filters RESTful Controllers Database Model using Eloquent ORM Creating A Migration Code Example Questions Abuzer Firdousi
  • 4. Laravel Philosophy Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tas • ROR • ASP.NET MVC • Sinatra (Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort) Laravel is accessible, yet powerful, providing powerful tools needed for large, robust applications. Laravel, the elegant PHP framework for web artisans Abuzer Firdousi
  • 5. Server Requirements The Laravel framework has a few system requirements: • PHP >= 5.3.7 • MCrypt PHP Extension As of PHP 5.5, some OS distributions may require you to manually install the PHP JSON extension. When using Ubuntu, this can be done via apt-get install php5-json. MCrypt: 1. aptitude install php5-mcrypt 2. echo extension=php_mcrypt.so >> /etc/php5/apache2/php.ini 3. /etc/init.d/apache2 restart Abuzer Firdousi
  • 6. Installation Laravel utilizes Composer to manage its dependencies. First, download a copy of the composer.phar. Via Composer Create-Project You may install Laravel by issuing the Composer create-project command in your terminal: composer create-project laravel/laravel --prefer-dist Via Download Once Composer is installed, download the latest version of the Laravel framework and extract its contents into a directory on your server. Next, in the root of your Laravel application, run the php composer.phar install (or composer install) command to install all of the framework's dependencies. This process requires Git to be installed on the server to successfully complete the installation. If you want to update the Laravel framework, you may issue the php composer.phar update command. Laravel provides a server, and we can run the server with “php artisan* serve” * command-line interface, a powerful Symfony Console component Abuzer Firdousi
  • 7. Basic Routing Most of the routes for your application will be defined in the app/routes.php file. The simplest Laravel routes consist of a URI and a Closure callback. Basic GET Route: Route::get('/', function() { return 'Hello World'; }); Basic POST Route: Route::post('foo/bar', function() { return 'Hello World'; }); Abuzer Firdousi
  • 8. Route Parameters Route Parameters: Route::get('user/{id}', function($id) { return 'User '.$id; }); Optional Route Parameters: Route::get('user/{name?}', function($name = null) { return $name; }); Throwing 404 Errors: There are two ways to manually trigger a 404 error from a route. First, you may use the App::abort method: App::abort(404); Abuzer Firdousi
  • 9. Requests & Input Retrieving An Input Value $name = Input::get('name'); Retrieving A Default Value If The Input Value Is Absent $name = Input::get('name', Abuzer); Getting All Input For The Request $input = Input::all(); Abuzer Firdousi
  • 10. Request Life Cycle The Laravel request lifecycle is fairly simple. A request enters your application and is dispatched to the appropriate route or controller. The response from that route is then sent back to the browser and displayed on the screen. Sometimes you may wish to do some processing before or after your routes are actually called. There are several opportunities to do this, two of which are "start" files and application events. Abuzer Firdousi
  • 11. Controllers Instead of defining all of your route-level logic in a single routes.php file, you may wish to organize this behavior using Controller classes. Controllers can group related route logic into a class, as well as take advantage of more advanced framework features such as automatic dependency injection. Controllers are typically stored in the app/controllers directory, and this directory is registered in the class map option of your composer.json file by default. Here is an example of a basic controller class: class UserController extends BaseController { /** * Show the profile for the given user. */ public function showProfile($id) { $user = User::find($id); // return Response::json( array('user' => $user) ); } } Abuzer Firdousi
  • 12. Controllers and Routes All controllers should extend the BaseController class. The BaseController is also stored in the app/controllers directory, and may be used as a place to put shared controller logic. The BaseController extends the framework's Controller class. Now, We can route to this controller action like so: Route::get('user/{id}', 'UserController@showProfile'); If you choose to nest or organize your controller using PHP namespaces, simply use the fully qualified class name when defining the route: Route::get('foo', 'NamespaceFooController@method'); You may also specify names on controller routes: Route::get('foo', array('uses' => 'FooController@method', 'as' => 'name')); Abuzer Firdousi
  • 13. Controller Filters Filters may be specified on controller routes similar to "regular" routes: ( Kind of Request INTERCEPTOR) Route::get('profile', array('before' => 'auth', 'uses' => 'UserController@showProfile')); However, you may also specify filters from within your controller: class UserController extends BaseController { /** * Instantiate a new UserController instance. */ public function __construct() { $this->beforeFilter('auth', array('except' => 'getLogin')); $this->afterFilter('log', array('only' => array('fooAction', 'barAction'))); } } Abuzer Firdousi
  • 14. RESTful Controllers Laravel allows you to easily define a single route to handle every action in a controller using simple, REST naming conventions. First, define the route using the Route::controller method: Defining A RESTful Controller Route::controller('users', 'UserController'); The controller method accepts two arguments. The first is the base URI the controller handles, while the second is the class name of the controller. Next, just add methods to your controller, prefixed with the HTTP verb they respond to: class UserController extends BaseController { public function getIndex() { // } public function postIndex() { // } public function putIndex() { // } public function deleteIndex() { // } } Abuzer Firdousi
  • 15. Eloquent ORM The Eloquent ORM included with Laravel provides a beautiful, simple ActiveRecord implementation for working with your database. Each database table has a corresponding "Model" which is used to interact with that table. Before getting started, be sure to configure a database connection in app/config/database.php. class User extends Eloquent { protected $table = 'my_users'; } Retrieving All Models $users = User::all(); Retrieving A Record By Primary Key $user = User::find(1); Querying Using Eloquent Models $users = User::where('votes', '>', 100)->take(10)->get(); foreach ($users as $user) var_dump($user->name); Abuzer Firdousi