Hybrid View
-
9 May 2009 1:19 PM #1
Ext.Direct PHP backend
Ext.Direct PHP backend
1/25/2010
Found a few bugs when working with Ext-3.1.0 (my mistakes, not Ext's). Updated the zip file. You should be able to unzip into your examples directory (in your Ext install), and run from there.
Biggest change was due to my incorrect handling of the formHandler value required by the API. So that the API generator can detect that a particular method is a form handler, you need to add frmHandler to your method name. You can see the comments in the Profile.php class file. There was really no way that I could see of getting that info using Reflections. Someone smarter than me may have a better idea here.
Remember the main goal (at least for me) was to simply write the php code, and then have the config and api generated from the classes, instead of having to manually create and maintain them.
Demo is working with 3.1 just fine, and the demo link below has been updated to the Ext-3.1.0 version.
---------------------------------------------------------------------------------
7/11/2009
Missed a variable name change in the before and after calls.
Fixed.
7/9/2009
Fixed router for multiple arguments in actions (finally). I misunderstood what was happening there. But this should be good to go now.
Zip has been updated.
Demo here.
---------------------------------------------------------------------------------
6/17/09
Fixed router to better handle parameters
Update demo page (with form, and tree examples)
Updated the attachment with latest changes.
---------------------------------------------------------------------------------
6/5/09
Fixed router to handle parameters properly
Fixed utils to handle multiple server action classes
Updated the attachment with latest changes.
---------------------------------------------------------------------------------
Ext.Direct PHP backend
First I am not a developer, more of a guy that likes to hack around. So this is by no means and end all solution. In fact, it might just be drivel. But while working with the examples and attempting to see how I could do some comet long polling stuff, I have re-worked the PHP backend for Ext.Direct just a bit.
Might want to save your originals before unzipping.Last edited by ckr; 5 Jan 2012 at 2:58 PM. Reason: New URL - Things are working again!!
Thanks!
Chuck
-
27 May 2009 6:27 PM #2
**Updated*** So that this is more functional (the previous post is blah)
First thing to note however, is if you need a really robust solution, I would suggest looking at Tommy's solution here. So maybe this should be viewed as a "Lite" implementation.
I was looking for something a little more lightweight and less involved. So I completely rewrote the previous approach. This now supports the len, and the before and after calls. All you do is build your actions class in PHP, and plop it in the proper directory. I used this reference as a guide for working with Reflections in PHP.
The router.php is very similar to the example one provided with the release. I have added some comments, but the only portion that I really altered was the RPC portion. That has been completely redone.
baseAPI.php has been replaced by extBaseProvider.php and there is now a small additional utils.php file.
The attachment can be unzipped in the examples/direct/ directory (make a backup of yours first). Be sure to read the embedded comments for additional info. Maybe this will help someone. Just thought I would share.Thanks!
Chuck
-
31 May 2009 7:10 PM #3
-
4 Jun 2009 5:07 AM #4
Since I never heard anything on this
and now that we have some better examples with 3.0RC2, there is one change that is needed in the utils.php to support multiple server side action classes. Red code is removed, Blue is the replacement.
utils.ph - function buildAPI
This change basically flattens the array of the server classes, so that when the JSON is built, it adds the server classes as a property to the Ext.RemotingProvider actions object.Code:function buildAPI($myObj) { $myClass = new ReflectionClass($myObj); $myProp = array(); $data = array(); foreach(array_values($myClass->getProperties()) as $property) { if ($property->isPublic()) { $propName = $property->name; $propValue = $property->getValue($myObj); if ((!is_object($propValue))&&(!is_array($propValue))) { $data[$propName] = $propValue; } else { // Added this bit, in the event that this // should be an array (which I think it should be // but for now will leave as is) // if (is_object($propValue)) { $data[$propName] = getActions($propValue); } elseif (is_array($propValue)) { foreach($propValue as $obj) { $data[$propName][] = getActions($obj); if (!array_key_exists($propName, $data)) { $data[$propName] = getActions($obj); } else { $data[$propName] = array_merge($data[$propName], getActions($obj)); } } } else { die("Unexpected data type encountered..."); } } } } return $data; }
Once this change is in place, all of the new demos work.Thanks!
Chuck
-
5 Jun 2009 5:23 AM #5
See first post for new attachment with latest fixes.
Thanks!
Chuck
-
17 Jun 2009 7:57 PM #6
Another small update to the router when passing more than one parameter.
Updated the demo page here, all using this interface.
Updated the zip on the first post.Thanks!
Chuck
-
25 Jan 2010 9:36 AM #7
Download zip out of sync with online demo?
Download zip out of sync with online demo?
Hi! Great lib!
It seems like the php-lib download is out of sync with your direct-demo though.
1. JavaScript error: out.el not defined (Might be caused by the current 3.1?)
2. There seems to be missing actions for fileList, updateChart etc...
Corrections or new exciting versions in the pipe? :-)
Regards / Jonas
-
25 Jan 2010 10:46 AM #8
Hey Cambiata. Thanks for the heads up.
Real work has been keeping me busy. I will look into it and let you know.Thanks!
Chuck
-
26 Jan 2010 4:42 AM #9
Ok - So the out.el not defined was simply an error when attempting to write out to the status window before it was actually rendered. So now when you load the demo page, you will see the status window (some might not have even noticed that it was there), and then it will collapse. You can expand it at any time. I have dumped this demo in my 3.1 install and everything is work fine.
I did make a few small changes, see the first post in this thread.
Enjoy!Thanks!
Chuck
-
18 Feb 2010 6:29 AM #10
Hi,
i can“t figure out how to handle PHP-Sessions with your Ext.Direct Implementation.
Can you offer an example?
Bye, Dumbledore


Reply With Quote