Skip to content

Instantly share code, notes, and snippets.

@jasonjohnson
Created June 14, 2014 02:50
Show Gist options
  • Save jasonjohnson/5cab9571c445084048a2 to your computer and use it in GitHub Desktop.
Save jasonjohnson/5cab9571c445084048a2 to your computer and use it in GitHub Desktop.
ZF2 JSON-RPC
#!/bin/bash
curl \
-X POST \
-d '{"method": "add", "params": [1, 2], "id": 1}' \
http://127.0.0.1:8080/server.php
{
"require": {
"zendframework/zend-json": "2.3.0",
"zendframework/zend-server": "2.3.0"
}
}
<?php
require 'vendor/autoload.php';
class Example
{
function add($a, $b)
{
return $a + $b;
}
}
$server = new Zend\Json\Server\Server();
$server->setClass('Example');
$server->handle();
#!/bin/bash
php composer.phar install
php -S 0.0.0.0:8080
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment