How to create web-services in Zend Framework?

2019-03-20 15:11发布

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

An example code will be useful.

1条回答
乱世女痞
2楼-- · 2019-03-20 15:40
<?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
查看更多
登录 后发表回答