SlideShare una empresa de Scribd logo
1 de 17
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

SharePoint Online vs. On-Premise
SharePoint Online vs. On-PremiseSharePoint Online vs. On-Premise
SharePoint Online vs. On-Premise
Evan Hodges
 

La actualidad más candente (20)

Troubleshooting Complex Oracle Performance Problems with Tanel Poder
Troubleshooting Complex Oracle Performance Problems with Tanel PoderTroubleshooting Complex Oracle Performance Problems with Tanel Poder
Troubleshooting Complex Oracle Performance Problems with Tanel Poder
 
R12.2 dba
R12.2 dbaR12.2 dba
R12.2 dba
 
Web services and SOA
Web services and SOAWeb services and SOA
Web services and SOA
 
MS SQL 2012 安裝與基本使用教學
MS SQL 2012 安裝與基本使用教學MS SQL 2012 安裝與基本使用教學
MS SQL 2012 安裝與基本使用教學
 
SharePoint Online vs. On-Premise
SharePoint Online vs. On-PremiseSharePoint Online vs. On-Premise
SharePoint Online vs. On-Premise
 
OOW16 - Oracle Enterprise Manager 13c Cloud Control for Managing Oracle E-Bus...
OOW16 - Oracle Enterprise Manager 13c Cloud Control for Managing Oracle E-Bus...OOW16 - Oracle Enterprise Manager 13c Cloud Control for Managing Oracle E-Bus...
OOW16 - Oracle Enterprise Manager 13c Cloud Control for Managing Oracle E-Bus...
 
Performance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresPerformance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and Underscores
 
Clase 5 Ejercicios de Normalización de Base de Datos
Clase 5 Ejercicios de Normalización de Base de DatosClase 5 Ejercicios de Normalización de Base de Datos
Clase 5 Ejercicios de Normalización de Base de Datos
 
Oracle OSB Tutorial 1
Oracle OSB Tutorial 1Oracle OSB Tutorial 1
Oracle OSB Tutorial 1
 
Microsoft 365 Chicago - eDiscovery and Microsoft Teams
Microsoft 365 Chicago - eDiscovery and Microsoft TeamsMicrosoft 365 Chicago - eDiscovery and Microsoft Teams
Microsoft 365 Chicago - eDiscovery and Microsoft Teams
 
The SharePoint Business Analyst Guide
The SharePoint Business Analyst GuideThe SharePoint Business Analyst Guide
The SharePoint Business Analyst Guide
 
OOW16 - Testing Oracle E-Business Suite Best Practices [CON6713]
OOW16 - Testing Oracle E-Business Suite Best Practices [CON6713]OOW16 - Testing Oracle E-Business Suite Best Practices [CON6713]
OOW16 - Testing Oracle E-Business Suite Best Practices [CON6713]
 
Part 2 -Deep Dive into the new features of Sharepoint Online and OneDrive for...
Part 2 -Deep Dive into the new features of Sharepoint Online and OneDrive for...Part 2 -Deep Dive into the new features of Sharepoint Online and OneDrive for...
Part 2 -Deep Dive into the new features of Sharepoint Online and OneDrive for...
 
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1
Tanel Poder - Troubleshooting Complex Oracle Performance Issues - Part 1
 
Presentation oracle net services
Presentation    oracle net servicesPresentation    oracle net services
Presentation oracle net services
 
mod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLImod_php vs FastCGI vs FPM vs CLI
mod_php vs FastCGI vs FPM vs CLI
 
October OpenNTF Webinar - What we like about Domino/Notes 12, recommended new...
October OpenNTF Webinar - What we like about Domino/Notes 12, recommended new...October OpenNTF Webinar - What we like about Domino/Notes 12, recommended new...
October OpenNTF Webinar - What we like about Domino/Notes 12, recommended new...
 
Apache ppt
Apache pptApache ppt
Apache ppt
 
Opendj - A LDAP Server for dummies
Opendj - A LDAP Server for dummiesOpendj - A LDAP Server for dummies
Opendj - A LDAP Server for dummies
 
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...
 

Destacado

Laravel Restful API and AngularJS
Laravel Restful API and AngularJSLaravel Restful API and AngularJS
Laravel Restful API and AngularJS
Blake Newman
 
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
Matthew Turland
 
Control interno
Control internoControl interno
Control interno
eikagale
 
Asp.net architecture
Asp.net architectureAsp.net architecture
Asp.net architecture
Iblesoft
 

Destacado (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 a Web services with laravel

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
 
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
annalakshmi35
 
Lecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptxLecture 2_ Intro to laravel.pptx
Lecture 2_ Intro to laravel.pptx
SaziaRahman
 

Similar a Web services with laravel (20)

Laravel 5
Laravel 5Laravel 5
Laravel 5
 
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
 
Creating your own framework on top of Symfony2 Components
Creating your own framework on top of Symfony2 ComponentsCreating your own framework on top of Symfony2 Components
Creating your own framework on top of Symfony2 Components
 

Más de Confiz

DMAIC-Six sigma process Improvement Approach
DMAIC-Six sigma process Improvement ApproachDMAIC-Six sigma process Improvement Approach
DMAIC-Six sigma process Improvement Approach
Confiz
 
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 types
Confiz
 
Sqa, test scenarios and test cases
Sqa, test scenarios and test casesSqa, test scenarios and test cases
Sqa, test scenarios and test cases
Confiz
 
Entity framework code first
Entity framework code firstEntity framework code first
Entity framework code first
Confiz
 
Security testing presentation
Security testing presentationSecurity testing presentation
Security testing presentation
Confiz
 
Ts seo t ech session
Ts   seo t ech sessionTs   seo t ech session
Ts seo t ech session
Confiz
 
Learning as a creative professional
Learning as a creative professionalLearning as a creative professional
Learning as a creative professional
Confiz
 
Learning as a creative professional
Learning as a creative professionalLearning as a creative professional
Learning as a creative professional
Confiz
 
Ts archiving
Ts   archivingTs   archiving
Ts archiving
Confiz
 
Advance text rendering in i os
Advance text rendering in i osAdvance text rendering in i os
Advance text rendering in i os
Confiz
 
Ts threading
Ts   threadingTs   threading
Ts threading
Confiz
 
Ts android supporting multiple screen
Ts   android supporting multiple screenTs   android supporting multiple screen
Ts android supporting multiple screen
Confiz
 
Ts drupal6 module development v0.2
Ts   drupal6 module development v0.2Ts   drupal6 module development v0.2
Ts drupal6 module development v0.2
Confiz
 
Photoshop manners
Photoshop mannersPhotoshop manners
Photoshop manners
Confiz
 
Monkey talk
Monkey talkMonkey talk
Monkey talk
Confiz
 
An insight to microsoft platform
An insight to microsoft platformAn insight to microsoft platform
An insight to microsoft platform
Confiz
 
Ts branching over the top
Ts   branching over the topTs   branching over the top
Ts branching over the top
Confiz
 

Más de 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
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
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
vu2urc
 

Último (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 

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