-
26 May 2012 5:43 AM #81
Hi Mate, been so long
can you make a laravel bundle for this? please 
-
26 May 2012 7:49 AM #82
1. Create folder laravel/bundles
2. Copy Bruni's ExtDirect.php into that folder
3. Create laravel/bundles/direct/start.php:
4. Add it to your application/bundles.phpCode:require_once(Bundle::path('direct').'ExtDirect.php'); // J Bruni
Start routing to your direct bundle !Code:return array( 'direct'=>array('handles'=>'direct') );
In other words, there's nothing for Bruni to do. His work is awesome.
Just follow the simple recipe at laravel for creating bundles. Ask for help at that site.
Or don't bother. It's just as easy to use as a library.
You have to read his code. Everything is there. But it will need to be tweaked for your situation.
His controller does not return to the laravel core, he simply spits out the results when ready.
Laravel dudes would frown. Whether you need to take that further depends again on your situation.
But you know what? I am finding ExtDirect is sucking away my life for no fun.
It creates challenges in the build and with using SA. It is always wanting extra attention for this or that.
For me, it has slowed progress considerably, and I regret using it.
Just look at all of bruni's code (which is now your own to understand and manage).
You'll need to discover how to use it with SA. Thats sucks away a bit.
And getting it right (do not try to execute before Ext is loaded, delaying creation of stores until provider is ready) may be no brainer for the experienced dudes, but it tripped me many times.
And for what exactly? Know your use cases and motivation. Plan on extra delays for ExtDirect.
Here (was) my laravel/bundles/direct/routes.php as I built the examples.
This was Day One code, I have since moved on...
If I had to do this again:Code://///////////////////////////////////////////////////////////////////////// /* * These first two routes implement JBruni's simple example. * * site.com/direct/example (JBruni would have used site.com/example.php, we drop the php extension) * site.com/direct/example.html (You need to edit direct/example.html to point to your ext install) */ Route::any('direct/example',function() { class Server { public function date( $format ) { return date( $format ); } } ExtDirect::$url=URL::to('direct/example'); ExtDirect::provide( 'Server' ); // poof our Server class is available to javascript }); Route::get('direct/example.html',function(){ return Response::make(file_get_contents(Bundle::path('direct').'example.html')); }); /* * Hmm. Now we need a page for the extjs samples. * * ExtAsset::sample takes an ordered list of scripts to add to direct/view/sample.php * That should give us a shell to test a couple of the ExtDirect sampless */ ///////////////////////////////////// Route::any('direct/test',function() { ExtDirect::$url=URL::to('direct/test'); ExtDirect::provide( 'TestAction' ); }); Route::any('direct/test.html',function() { ExtDirect::$url=URL::to('direct/test'); ExtAsset::sample(array('direct/test?javascript','apps/direct/test.js')); return View::make('direct::sample')->with('title', 'test'); }); ///////////////////////////////////////// // Service the polling demo. No class. Route::get('(:bundle)/poll', function() { $result=array( 'type'=>'event', 'name'=>'message', 'data'=>'Successfully polled at: '. date('g:i:s a') ); return new Response(json_encode($result),200, array('Content-Type'=>'application/json')); }); Route::any('direct/poll.html',function() { ExtDirect::$url=URL::to('direct/poll'); ExtAsset::sample(array('apps/direct/poll.js')); return View::make('direct::sample')->with('title', 'poll'); }); // Now we have a pattern, follow it for the other samples: grid, tree and named-arguments... Route::any('direct/tree',function() { IoC::resolve('TestAction'); ExtDirect::$url=URL::to('direct/tree'); ExtDirect::provide( 'TestAction' ); }); Route::any('direct/tree.html',function() { ExtDirect::$url=URL::to('direct/tree'); ExtAsset::sample(array('direct/tree?javascript','apps/direct/direct-tree.js')); return View::make('direct::sample')->with('title', 'tree'); }); // Route::any('direct/grid',function() { IoC::resolve('TestAction'); ExtDirect::$url=URL::to('direct/grid'); ExtDirect::provide( 'TestAction' ); }); Route::any('direct/grid.html',function() { ExtDirect::$url=URL::to('direct/grid'); ExtAsset::sample(array('direct/grid?javascript','apps/direct/direct-grid.js')); return View::make('direct::sample')->with('title', 'grid'); }); // Route::any('direct/named-arguments',function() { ExtDirect::$url=URL::to('direct/named-arguments'); ExtDirect::provide( 'TestAction' ); }); Route::any('direct/named-arguments.html',function() { ExtDirect::$url=URL::to('direct/named-arguments'); ExtAsset::sample(array('direct/named-arguments?javascript','apps/direct/named-arguments.js')); return View::make('direct::sample')->with('title', 'named-arguments'); });
- I would not bother making ExtDirect a bundle. Just drop it in your library and use it.
- I would not use ExtDirect without a serious motivation
Good luck.
And many thanks to J Bruni.
-
26 May 2012 11:22 AM #83
Hi Thanks for the detailed explanations
this is actually a debate to my self that i would just use simple api for this.. but ill try around see what fits..
-
29 Aug 2012 8:11 AM #84
Hello,
there is no simple way or documentation to use it with sencha architect ?
what alternative to ext.direct for using extjs with laravel along a simple approach ?
-
29 Aug 2012 8:29 AM #85
Like I say, I have moved on, but this is what worked for me at the time:
In other words, I gave SA a slightly different url for ExtDirect, so laravel could notice and set the output format accordingly.Code:// There are supposed to be formats attached to the request, eg ?xml ?json. // Thought ExtDirect handled it and thought I saw it working once. But this is okay for now. Route::any('direct/video, direct/arkvideo', function() { try{ // Laravel has sexier ways to do this I am sure. if (strstr(URI::current(),'ark')) { // Request is coming from the Sencha Architect (ark ark) ExtDirect::$default_api_output = 'json'; } else { // Service for ext apps ExtDirect::$default_api_output = 'javascript'; }
Cheesy but easy.
-
29 Aug 2012 8:40 AM #86
-
29 Aug 2012 10:54 AM #87
-
30 Aug 2012 1:37 AM #88
JSON x JavaScript output
JSON x JavaScript output
This ExtDirect class does provide a shortcut to select between JSON or JavaScript output, which is to provide a "javascript" parameter in the query string of the requested URL. For example:
http://domain.com/direct/example - this outputs JSON
http://domain.com/direct/example?javascript - this outputs JavaScript
This is performed at ExtDirectController::get_api method, as seen below:
The "core" of it is the isset( $_GET['javascript'] ) snippet.PHP Code:/**
* @return string JSON or JavaScript API declaration for the classes on "api_classes" configuration array
*/
public function get_api()
{
if ( isset( $_GET['javascript'] ) || ( ExtDirect::$default_api_output == 'javascript' ) )
return ExtDirect::get_api_javascript();
else
return ExtDirect::get_api_json();
}
-
30 Aug 2012 10:04 AM #89
-
30 Oct 2012 11:11 AM #90
I am wondering the same thing, and if the response that follows is still relevant.
I am using the sample descriptor code (for PHP) that is provided with the Ext Direct Pack and the mechanism for setting default configuration values seems to have changed:
Regarding ExtJS Direct configuration, in general, I am wondering if these configuration directives are still relevant:PHP Code:$api = new ExtDirect_API();
$api->setRouterUrl('router.php'); // default
$api->setCacheProvider($cache);
$api->setNamespace('Ext.ss');
$api->setDescriptor('Ext.ss.APIDesc');
$api->setDefaults(array(
'autoInclude' => true,
'basePath' => 'classes'
));
Does current (ExtJS 4+), formal documentation of these directives exist? If so, might anyone be able to provide a URL? I have looked and came-up empty.
Thanks in advance.
Similar Threads
-
Ext.Direct PHP backend
By ckr in forum Ext.DirectReplies: 34Last Post: 11 Jun 2012, 1:30 PM -
Alternative Ext Direct PHP Implementation
By TommyMaintz in forum Ext.DirectReplies: 36Last Post: 26 Sep 2011, 12:08 AM -
Easy Ext.Direct integration with PHP
By j.bruni in forum Ext.DirectReplies: 2Last Post: 23 Jun 2010, 11:27 AM -
Simple Ext.Direct PHP apps
By pkristiana in forum Community DiscussionReplies: 1Last Post: 11 Feb 2010, 1:12 AM


Reply With Quote