PHP code example of dittertp / extdirect
1. Go to this page and download the library: Download dittertp/extdirect library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dittertp / extdirect example snippets php
rect\ExtDirect;
$direct = new ExtDirect();
$direct->setApplicationNameSpace("ExtDirectDemoApp");
$direct->setApplicationPath("ExtDirectDemoApp");
$api = $direct->getApi();
$api->setUrl("extDirect.php");
$api->setNameSpace("Ext.app");
$jsonApi = $api->getApi();
echo $jsonApi;
php
rect\ExtDirect;
$request = array();
$request['type'] = "rpc";
$request['tid'] = 1;
$request['action'] = "DemoApp";
$request['method'] = "getTree";
$request['data'] = array("demoKey"=>"demoValue");
$direct = new ExtDirect();
$direct->setApplicationNameSpace("ExtDirectDemoApp");
$direct->setApplicationPath("ExtDirectDemoApp");
$direct->call("init", array("initparameter"));
$direct->setParamMethod("setParams");
$direct->processRequest($request);
$result = $direct->getResponse()->asArray();
print_r($result);
php
rect\ExtDirect;
$request1 = array();
$request1['type'] = "rpc";
$request1['tid'] = 1;
$request1['action'] = "DemoApp";
$request1['method'] = "getTree";
$request1['data'] = array("demoKey"=>"demoValue");
$request2 = array();
$request2['type'] = "rpc";
$request2['tid'] = 2;
$request2['action'] = "DemoApp";
$request2['method'] = "getList";
$request2['data'] = array("demoKey"=>"demoValue");
$request = array($request1, $request2);
$direct = new ExtDirect();
$direct->setApplicationNameSpace("ExtDirectDemoApp");
$direct->setApplicationPath("ExtDirectDemoApp");
$direct->call("init", array("initparameter"));
$direct->setParamMethod("setParams");
$direct->processRequest($request);
$result = $direct->getResponse()->asArray();
print_r($result);
php
/**
* @Direct(name="DemoApp")
*/
class DemoAppController
{
/**
* @Remotable(name = "getTree")
*/
public function TreeAction()
{
return array("success"=>true);
}
/**
* @Remotable(name = "getList")
*/
public function ListAction()
{
return array("success"=>true);
}
bash
cd Example
php api.php
php direct.php
php batchedDirect.php