{"id":25470151,"url":"https://github.com/thinkphp/json-rpc-php","last_synced_at":"2025-11-04T18:30:29.811Z","repository":{"id":66903051,"uuid":"1146119","full_name":"thinkphp/json-rpc-php","owner":"thinkphp","description":"Implementation of the JSON-RPC protocol in PHP","archived":false,"fork":false,"pushed_at":"2010-12-09T12:25:11.000Z","size":109,"stargazers_count":17,"open_issues_count":1,"forks_count":13,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-04-14T14:54:26.635Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://thinkphp.ro/apps/php-hacks/json-rpc-php/client.php","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thinkphp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-12-07T10:26:58.000Z","updated_at":"2020-05-11T10:21:10.000Z","dependencies_parsed_at":"2023-02-20T14:00:21.418Z","dependency_job_id":null,"html_url":"https://github.com/thinkphp/json-rpc-php","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp%2Fjson-rpc-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp%2Fjson-rpc-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp%2Fjson-rpc-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thinkphp%2Fjson-rpc-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thinkphp","download_url":"https://codeload.github.com/thinkphp/json-rpc-php/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239437226,"owners_count":19638449,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-18T08:32:09.219Z","updated_at":"2025-11-04T18:30:29.769Z","avatar_url":"https://github.com/thinkphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"JSON-RPC-PHP \u003c=\u003e Implementation of the JSON-RPC protocol in PHP\n---------------------------------------------------------------\n\nThis is a couple of classes written in PHP implementing respectively client and server functionalities of the [JSON-RPC](http://json-rpc.org/) protocol.\nThe goal of the project is the full incapsulation of the JSON-RPC approach inside a PHP application. Via these classes, it becomes possible to offer the network the methods of each one's own classes as RPC services and enjoy RPC services exactly as if they were local objects.\nThe JSON-RPC-PHP classes usage is extremely simple and preserve the JSON spirit.\n\n## Introduction\n\n``Interoperability`` is a property referring to the ability of diverse systems and organizations to work together (inter-operate).Alors, the term\niteroperability is used to describe the capability of different programs to exchange data via a common set of exchange formats, to\nread and write the same file formats, and  to use the same protocols. According to ISO/IEC 2382, interoperability is defined as follows: \n\"The capability to communicate, execute programs, or transfer data among various functional units in a manner that requires the user to have little or no knowledge of the unique characteristics of those unites\".\n\n``Remote procedure call (RPC)`` is a technology that allows a computer program to cause a subroutine or procedure to execute in \nanother address space (commonly on another computer on a shared network) without the programmer explicitly coding the details\nfor this remote interaction. That is, the programmer writes essentially the same code whether the subroutine is local to the executing program, or remote.\n\nTraditionally, the most common tools to implement RPC techniques are or have been: [ONC-RPC](http://en.wikipedia.org/wiki/ONC_RPC), [Corba](http://en.wikipedia.org/wiki/CORBA), [Java RMI](http://en.wikipedia.org/wiki/Java_Remote_Method_Invocation), [XML-RPC](http://en.wikipedia.org/wiki/XML-RPC), [SOAP](http://en.wikipedia.org/wiki/SOAP).\nHowever, none of these seems to be enough general to be used easly in different environements. The packaging appear hard to read for humans because the complex\nencapsulations and the ``strong typing`` makes the protocols hard for the ``weak typing`` programming languages, like PHP.\n\nIn the latest years, a new technology evolved and become stable, very interesting for encapsulation of complex data in a light logic and a simple format: [JSON](http://json.org/).\n\n``JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate``.\n\nBesides being easy to read for both humans and machines, JSON doesn't need to specify the type of the variables involved. This fact makes JSON the structured format more portable on the interoperatability scene.\n\nNext to the JSON success, an RPC technique has born, following the XML-RPC idea and taking the name [JSON-RPC](http://json-rpc.org/).\n\n``JSON-RPC is lightweight remote procedure call protocol similar to XML-RPC. It's designed to be simple! ``\n\n\nOverview:\n----------\n\nThe ``JSON-RPC`` goal is to make the network walking fully transparent to the programming. The idea is that an object X created in the host S (server) could be used from the host C (client) as if it was an internal object, whos behavoir was identical to the object in the S host. \nTo grant this, naturally, in the host S must be present  and running the server ``jsonRPCServer``, that is a class with one static method incapsulating the requested object in a JSON-RPC service and serving it to the consumers coming from the network. Similary, in the host C must be present the client ``jsonRPCClient``, that is a class\nincapsulating the object methods through the network, that is creating objects for the C environement acting exactly as the O object packaged in the server side.\n\nHow to use:\n-----------\n\nOn the server side, the ``jsonRPCServer`` class has simply one static method. So, no objects have to be instanced. However, the object animating the service must be instanced since the creation normally establishes the interaction of the object with the local enviroment (the database connection, some filesystem path, some configuration parameter, etc.).\nThe server may look like this:\n\n       \u003c?php\n       require_once('jsonRPCServer.php');\n       include('math.php');\n       $obj = new Math();\n       jsonRPCServer::handle($obj) or print('no request');\n       ?\u003e\n\nAs you can see, the object is passed to the server in its current state. So it is possible to give the server an object with a previous life longer than a fresh created object, that is an object with an internal state more sofisticated than a new object. Once the object is given to the server, all its methods will be available as ``JSON-RPC`` requests.\n\n\nOn the client side, things are even more easy. Once known the existence of a service at a given URL, it is simply necessary to create a ``jsonRPCClient`` object, instanced passing the server URL to the constructor.\n\n\n      \u003c?php\n      require_once('jsonRPCClient.php');\n      $client  = new jsonRPCClient('http://aldovet.ro/json-rpc-php/server.php');\n      try {\n         echo$client-\u003egetTweets('thinkphp',10,true); \n      }catch(Exception $e) {\n         echo$e-\u003egetMessage(); \n      }\n      ?\u003e\n\nThe object ``$client`` so created in the host __C__ will behave exactly like the ``$client`` object of the __S__ host.\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkphp%2Fjson-rpc-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthinkphp%2Fjson-rpc-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthinkphp%2Fjson-rpc-php/lists"}