Silex-Direct
An ExtDirect service provider for Silex., (*1)
Installation
Through Composer:, (*2)
{
require: {
"oaugustus/direct-silex-provider": "dev-master"
}
}
Usage
To get up and running, register DirectExtension and
manually specify the bundles directories that will be the controllers exposed
to ExtDirect., (*3)
Register the DirectServiceProvider;, (*4)
// app.php
...
$app->register(new Direct\DirectServiceProvider(), array());
Expose the controllers., (*5)
// app.php
...
// method call without formHandler
$app->post('/controller/method', function() use($app){
return $app["request"]->get("name");
})->direct();
// method call with formHandler
$app->post('/controller/secondMethod', function(){
})->direct(true);
Add the api call into your page templates:, (*6)
<script type="text/javascript" src="{{url('directapi')}}"></script>
Ready, now call the remote method from ExtJS code:, (*7)
Actions.Controller.method({name: 'Otavio'}, function(result, ev){
if (ev.type != 'exception')
console.log(result);
});