Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create web-services in Zend Framework?

How to create web services over HTTP REST protocol using Zend Framework?

An example code will be useful.

like image 950
Karthik Avatar asked Feb 08 '11 06:02

Karthik


1 Answers

<?php

// include zend framework in the include path

function methodname($var) {
echo "Hello world - $var";
}

$server = new Zend_Rest_Server();
$server->addFunction('methodname');
$server->handle();
?>

To call this web service, open the URL where you have saved this PHP file with the following arguments

http://www.example.com/index.php?method=methodname&var=Test

which will give output of

Hello world - Test
like image 109
Lenin Raj Rajasekaran Avatar answered Oct 13 '22 01:10

Lenin Raj Rajasekaran