SlideShare a Scribd company logo
PHP and Web Services
Bruno Pedro <bpedro@computer.org>
CITOT - May 20th 2007
PHP andWeb Services
Summary
• What is PHP?
• Web Services
• SOAP
• REST
• JSON
• Conclusions
2
PHP andWeb Services
What is PHP?
• PHP: Hypertext Preprocessor
• Open Source Web scripting language
• Created in 1994
• Syntax inherited from C, Java and Perl
• Powerful, yet easy to learn
3
PHP andWeb Services
How is PHP used?
• Content Management
• Forums
• Blogging
• Wiki
• CRM
4
PHP andWeb Services
Who uses PHP?
Source: Zend
5
PHP andWeb Services
Why use PHP?
• Used by 20M+ Web Sites around the globe
• Community-maintained documentation
• Code runs on UNIX, OSX and Windows
• Backed commercially by Zend
• Easy syntax
6
PHP andWeb Services
The PHP language
7
Easy syntax!
PHP andWeb Services
Creating a function
8
function declaration
return value
function call
PHP andWeb Services
Creating a class
9
class declaration
public method
method call
PHP andWeb Services
Web Services
10
Source:The Server Side
(http://tinyurl.com/38umxt)
PHP andWeb Services
What are Web Services?
• Interoperable interactions
• Calls are made over a network
• Lots of different standards
• Popular Web sites use them
11
PHP andWeb Services
Requirements
• PHP 5.2.2
• SOAP
• simplexml
• DOM
• JSON
12
PHP andWeb Services
SOAP
Source: Prentice Hall
(http://tinyurl.com/33dcch)
13
PHP andWeb Services
SOAP
• Simple Object Access Protocol
• Usually an HTTP POST request
• Call is encapsulated in XML
• Response is an XML document
• PHP handles everything
14
PHP andWeb Services
Server implementation
15
namespace
start a server
assign a class
handle incoming calls
PHP andWeb Services
Client implementation
16
namespace
endpoint
display result
PHP andWeb Services
Output
17
namespace
result
PHP andWeb Services
SOAP
18
• Support for SOAP 1.1, 1.2 and WSDL 1.1
• Handles simple and complex types
• Very easy implementation
• Output is quite bulky
PHP andWeb Services
REST
http://example.com/calculator/sum/?x=121&y=233
GET
PUT
POST
DELETE
«interface»
Resource
GET - perform a calculation
PUT - not used
POST - not used
DELETE - not used
/calculator/sum/
19
PHP andWeb Services
REST
• Representational State Transfer
• Usually an HTTP GET request
• Call is made through GET parameters
• Response is an XML document
• Create response with DOM
• Interpret response with simplexml
20
PHP andWeb Services
Server implementation
21
handle incoming call
create an
XML document
add elements
output result
PHP andWeb Services
Client implementation
22
endpoint
arguments
load XML document
output result
PHP andWeb Services
Output
23
result
PHP andWeb Services
REST
24
• Interaction needs to be implemented
• XML schema must be know beforehand
• Complex types not handled natively
• Output is usually RSS
PHP andWeb Services
JSON
25
JSON Logo
Source: json.org
PHP andWeb Services
JSON
• JavaScript Object Notation
• REST approach
• Except response is not XML
• Used on the client side
• Create response with json_encode()
• Interpret response in JavaScript
26
PHP andWeb Services
Server implementation
27
handle incoming call
generate result
output
JSON string
PHP andWeb Services
Client implementation
28
endpoint
arguments
output result
PHP andWeb Services
Output
29
result
PHP andWeb Services
JSON
30
• REST approach
• Handles simple and complex types
• Calls can be made with AJAX
• Can also be used on the server side
PHP andWeb Services
Conclusions
• PHP is a powerful web scripting language
• Too many Web Services standards
• PHP handles all the internals
• REST requires more coding than SOAP
• Use JSON for client side applications
• XML-RPC support is still experimental
31
PHP andWeb Services
Questions?
32
PHP andWeb Services
Resources
33
• My blog: http://unfoldingtheweb.com/
• PHP Manual: http://www.php.net/
• SOAP: http://www.w3.org/TR/soap/
• REST: http://tinyurl.com/akhc7
• JSON: http://www.json.org/

More Related Content

PDF
Php And Web Services
PDF
PHP client - Mongo db User Group Pune
PDF
Using Communication and Messaging API in the HTML5 World
PDF
OpenCms Days 2013 - A mail hosting service using OpenCms
PDF
Consuming RESTful services in PHP
ODP
REST services and IBM Domino/XWork - DanNotes 19-20. november 2014
PPT
Develop webservice in PHP
PDF
Web Services
Php And Web Services
PHP client - Mongo db User Group Pune
Using Communication and Messaging API in the HTML5 World
OpenCms Days 2013 - A mail hosting service using OpenCms
Consuming RESTful services in PHP
REST services and IBM Domino/XWork - DanNotes 19-20. november 2014
Develop webservice in PHP
Web Services

What's hot (9)

PDF
Introduction into PHP5 (Jeroen van Sluijs)
PDF
Plone Futures
PDF
PHP MySQL Training : Module 3
PDF
RichFaces 4 Component Deep Dive - JAX/JSFSummit
PDF
Plone server
PPTX
Webservices Overview : XML RPC, SOAP and REST
PDF
PHP and Web Services
PDF
USP presentation of CHOReOS @ FISL Conference
ODP
Linux Apache Php Mysql Lamp1273
Introduction into PHP5 (Jeroen van Sluijs)
Plone Futures
PHP MySQL Training : Module 3
RichFaces 4 Component Deep Dive - JAX/JSFSummit
Plone server
Webservices Overview : XML RPC, SOAP and REST
PHP and Web Services
USP presentation of CHOReOS @ FISL Conference
Linux Apache Php Mysql Lamp1273
Ad

Viewers also liked (20)

PPTX
Python Code Camp for Professionals 3/4
PDF
A python web service
PDF
Deep-dive into Django #1
PDF
Django Introduction & Tutorial
PPTX
Django Mini Tutorial
PDF
Django Girls / Dutch django meetup feb 2016
PPTX
Python Code Camp for Professionals 1/4
PDF
Django Templates
PDF
Intro To Mvc Development In Php
PDF
PHP MVC Tutorial
PDF
10 - Web-технологии. MVC фреймворки (продолжение)
ODP
Django for Beginners
PDF
PHP & MVC
PPT
How to learn to build your own PHP framework
PPTX
Django - Python MVC Framework
PDF
Django Best Practices
PDF
Python/Django Training
KEY
Advanced Django Forms Usage
PDF
Web Services PHP Tutorial
Python Code Camp for Professionals 3/4
A python web service
Deep-dive into Django #1
Django Introduction & Tutorial
Django Mini Tutorial
Django Girls / Dutch django meetup feb 2016
Python Code Camp for Professionals 1/4
Django Templates
Intro To Mvc Development In Php
PHP MVC Tutorial
10 - Web-технологии. MVC фреймворки (продолжение)
Django for Beginners
PHP & MVC
How to learn to build your own PHP framework
Django - Python MVC Framework
Django Best Practices
Python/Django Training
Advanced Django Forms Usage
Web Services PHP Tutorial
Ad

Similar to Php and webservices (20)

PDF
Php and-web-services-24402
PDF
Building Web Services
PDF
Integrating PHP With System-i using Web Services
PPTX
Developing Rich Internet Applications with Perl and JavaScript
PPTX
Datasnap
PDF
RESTful web
PPTX
Understanding and programming the SharePoint REST API
PDF
Webアプリケーションフレームワークを利用した効率的なカスタムWeb開発
PPTX
How to Supercharge your PHP Web API
PDF
Node.js to the rescue
PPTX
Php reports sumit
PPT
Introduction to Server-Side Development with PHP.ppt
PPTX
Nodejsvs
PPTX
Optimizing performance
PDF
Building high performance microservices in finance with Apache Thrift
PPT
Application layer
PDF
PHP Web Development Frameworks & Advantages
PPT
introduction to php notes for engineering students.ppt
PPT
PDF
Adding Real-time Features to PHP Applications
Php and-web-services-24402
Building Web Services
Integrating PHP With System-i using Web Services
Developing Rich Internet Applications with Perl and JavaScript
Datasnap
RESTful web
Understanding and programming the SharePoint REST API
Webアプリケーションフレームワークを利用した効率的なカスタムWeb開発
How to Supercharge your PHP Web API
Node.js to the rescue
Php reports sumit
Introduction to Server-Side Development with PHP.ppt
Nodejsvs
Optimizing performance
Building high performance microservices in finance with Apache Thrift
Application layer
PHP Web Development Frameworks & Advantages
introduction to php notes for engineering students.ppt
Adding Real-time Features to PHP Applications

Recently uploaded (20)

PDF
PSYCHOLOGY IN EDUCATION.pdf ( nice pdf ...)
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Open Quiz Monsoon Mind Game Prelims.pptx
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Onica Farming 24rsclub profitable farm business
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Insiders guide to clinical Medicine.pdf
PPTX
Cell Structure & Organelles in detailed.
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
Pre independence Education in Inndia.pdf
PDF
Open folder Downloads.pdf yes yes ges yes
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PSYCHOLOGY IN EDUCATION.pdf ( nice pdf ...)
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Open Quiz Monsoon Mind Game Prelims.pptx
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
Week 4 Term 3 Study Techniques revisited.pptx
Open Quiz Monsoon Mind Game Final Set.pptx
Anesthesia in Laparoscopic Surgery in India
Onica Farming 24rsclub profitable farm business
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Abdominal Access Techniques with Prof. Dr. R K Mishra
Insiders guide to clinical Medicine.pdf
Cell Structure & Organelles in detailed.
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Pre independence Education in Inndia.pdf
Open folder Downloads.pdf yes yes ges yes
Microbial disease of the cardiovascular and lymphatic systems
O7-L3 Supply Chain Operations - ICLT Program
3rd Neelam Sanjeevareddy Memorial Lecture.pdf

Php and webservices