-
Notifications
You must be signed in to change notification settings - Fork 0
Docs JsonRpc Proxies
In high performance applications, you may not want to generate the proxy classes for your service on-the-fly for each request. Stubbles provides a Phing task that can generate proxy classes for all services registered in the json-rpc-service.ini config file during the build process.
The target folder for the JavaScript proxy files can be specified in the json-rpc-service.ini using the genjsdir configuration. This folder will always be relative to the docroot folder of your project.
The JavaScript proxy namespace for the JavaScript files can also be specified in the json-rpc-service.ini using the namespace property.
The Stubbles build file build-stubbles.xml provides the generate-clients target, which will read the json-rpc-service.ini file and generate a JavaScript file per registered PHP class as well as a all-clients.js file that contains the proxy classes for all services.
To start the generation of the proxy clients you only need to type phing on the command line, after you set-up your project. If you changed the configuration, you only need to re-run phing to generate the clients based on the new configuration.
This will produce one file containing all proxies (allClient.js) and additionally separate files (one per proxy). If you are not using the allClients.js-file you have to initialize the (default or your own) namespace for yourself:
stubbles.json.proxy = {}; // XOR var my.own.ns = {};
Of course, you can also use the Phing task in your own build file. The following XML snippet shows, how the task is used to generate proxy clients:
<stubGenerateJsonRpcProxies serviceFile="path/to/json-rpc-service.ini" javaScriptNamespace="my.own.ns"/>