It is something that I had to think about in my day job, because my team is migrating to PHP for web development and I believe that we simply do not have enough time for them to learn JavaScript’s intricacies, I needed to be the one person who would have to wrestle JavaScript when problems happened. I therefore needed a way to insulate them from the gory details, which is why I created ExtPHP.
As you may have guessed from subtle hints, such as this entry’s 12-feet tall header, ExtPHP creates a PHP wrapper for ExtJS.
I noticed, at dzone.com, that the last time someone created a wrapper for JavaScript, many readers complained about how intrusive his approach was. Well, be assured that ExtPHP does not foil ExtJS’ non-intrusive take. Of course, with ExtJS itself, it’s up to the developer to decide what kind of style they wish to adopt, and ExtPHP follows suit.
I guess the introduction I wrote in ExtPHP’s documentation explains fairly clearly what the idea is: “ExtPHP is a wrapper for ExtJS. This is version 0.1, so I expect that a lot of things can be improved upon and your feedback is greatly appreciated. ExtPHP can be used to write both intrusive and non-intrusive Javascript, just like ExtJS itself. Use it responsibly. One of the many advantages of this design is that unknown/misspelled/misused methods are detected in your PHP editor rather than forcing you to debug your JavaScript code in your web browser. ”
Documentation? Indeed, I took some time to write a much-needed PDF document. Let me know how I can improve it, I am sure that you will find it lacking - because it is.
Anyway, I am releasing this as a “Technology Preview” and I will greatly appreciate your help beta-testing it.
Cheers.
Sphere: Related Content

Hi ,
just to warn u about ur link : hhttp….
Any thought on doing this with jQuery??
I see you are migrating to PHP can I suggest you take a look at the Andromeda Database Framework. Its a great framework written in PHP and does not require your to learn php
Donald:
Thanks, I’m going to take a look right away. I haven’t found a PHP framework that strikes the right balance, to my taste, yet, so hopefully ADF will be the one!
guebreg:
Thanks! What a silly mistake. *shakes head*
This is very interesting…good job!….
[…] Then Chris Ravenscroft came to me to announce ExtPHP: “It is something that I had to think about in my day job, because my team is migrating to PHP for web development and I believe that we simply do not have enough time for them to learn JavaScript’s intricacies, I needed to be the one person who would have to wrestle JavaScript when problems happened. I therefore needed a way to insulate them from the gory details, which is why I created ExtPHP.” […]
[…] Then Chris Ravenscroft came to me to announce ExtPHP: “It is something that I had to think about in my day job, because my team is migrating to PHP for web development and I believe that we simply do not have enough time for them to learn JavaScript’s intricacies, I needed to be the one person who would have to wrestle JavaScript when problems happened. I therefore needed a way to insulate them from the gory details, which is why I created ExtPHP.” […]
Hi,
thats a great Idea. i hope i will see it evolve, this can become a big thing ..
Can you already say something about the compatibility to Ext 2.0 ?
Benjamin, my testing was performed against Ext 2.0.1 and Ext 2.0.2.
Of course a lot more testing will be required to make it a good tool!
Hi, I’m testing this great wrapper, but I’m having some problem:
I do not find json.php, required in main.php. That file is suppose to be in libs/extphp, where all the generate classes are, but I don’t have json.php in that folder.
Any idea? What em I doing wrong?
Thanks
Lorenzo
Admin: Were you able to take a look at Andromeda?? If so what did you think, do you have any questions.
Until I started using Andromeda (and now a developer on the project), I coded everything from the ground up. Thats been for almost 10 years now.
And ever since I started using andromeda I havent thought about going back to hand coding….because with Andromeda if you so choose you can still hand code everything without breaking security or data integrity.
[…] ExtPHP: An ExtJS Converter/Wrapper for PHP Developers Enregistré dans : ExtJS — Rémi SOUBEYRAND @ 21:31 […]
[…] ExtPHP (13 visites) […]
[…] (categories: php javascript extjs php4) […]
Man, you are definitely beyond PHP-Ext, because:
- PHP-Ext try to be compatible to PHP4, which is a lost o time and features
- You use autoload. Really, I can´t understand how people live without it.
- You don´t rewrite nothing, and let the user keep updated with exJS by his own
- Your code style like:
width(300)->
height(150)->
is great! Looks like blocks/closures (wouldn´t be nice php support it?)
The only problem is that convertextjs.php is too complex. It could be splited in more files/classes. And the total absence of tests is a shame
Congratulation and good luck with the project!
@Lorenzo Could it be that I somehow forgot to wrap json.php in the archive? If so, I deeply apologize and I will make sure to fix this when I return from SXSW
@Donald Well, yes I have. This is different than what I expected: they have definitely focused on improving ActiveRecords’ semantics. Very interesting.
@Nevers and others Thanks for the comments. Actually I have some unit tests on my local disk I just didn’t wrap them because they aren’t a complete test suite. And yes, I shoved the whole converter in one big file, which makes it a big awkward to read I know :/
Regarding PHP-Ext, I believe that the author is pursuing different goals than I am. He obviously had to rewrite a lot of code due to the limitations of PHP4. I was free to ignore PHP4 and that certainly makes ExtPHP more flexible, at the price of being useless if your web host is still running PHP4
@Admin: Thanks for checking out our “un-framework” keep an eye on it in the coming weeks as we have a couple more anouncements/features that we will be anouncing.
Since you have taken the time to look at it you can see that this system of doing this take a different approach to a framework but still allows for rapid deployment as well as allows for much easier custom screens/pages than most traditional frameworks out there, as well as taking the validation away from the interface which is not always perfect it put the validation in the database level, this way you can never end up with invalid data.
If you continue to use it more, which I suggest you do because you wont realize the full potential until you have been using it for some time, check out our sourceforge site http://www.sourceforge.net/projects/andro as it is very active and if you have any issues/questions/feature requests or suggestions submit them and who know it might even be fixed/add that week depending on our schedules and if its something that intrigues us.
But thank you for taking a look at it. You are hoping to star development to allow for supporting other databases first on the list is MySQL.
[…] ExtPHP (0 visite) […]
[…] ExtPHP (0 visite) […]
Hmm, doesn’t work for me.
When i run convertextjs.php it gives me load of stuff scrolling and then next thing i know, it didnt generate any files for me. I even chmodded the whole directory to 777 just to make sure but still no go.
Any idea why?
[…] As both the Zend Developer Zone and Ajaxian point out, there’s been two new projects based on the Ext JS user interface widget system adapted for PHP - PHP-Ext and ExtPHP. PHP-Ext is an open source widget library written for PHP 4 and 5 to empower the UI Layer. It is based on Ext JS javascript widgets which provide a standard and powerful API to build Rich Internet Applications. It basically works as a convenient wrapper for the Ext JS Javascript Objects. […]
@james & @Lorenzo
Guys, I rewrapped the package. If you download it again from SourceForge, you will see that it now contains a proper json.php
To all,
I just want to know on how to integrate Cakephp with EXTJS?
pls help me….
Tnx.
A framework you might be interested in is SimplicityPHP which is integrated with Ext.
Hello!
Great work! Unfortunately I didn’t get it to work.
The sample code did not run until I’d made the following changes:
function __autoload($class_name) {
// CamelCase => camel_case
if (0 == strncmp($class_name, ‘Ext_’, 4))
{
$name = str_replace(’_Config’, ‘’, $class_name);
$name = str_replace(’_', ‘.’, $name);
$exploded = explode(’.', $name);
if (count($exploded) > 2) {
$exploded[1] = strtolower($exploded[1]);
$name = implode(’.', $exploded);
}
include_once(”libs/extphp/$name.php”);
}
}
Now I’m stuck with a javascript error: Ext is not defined…
Silly me! I forgot to place the ExtJS files in the correct directory.
Now it is running fine! Thx!
Seiti, glad to see that it is working.
Let me know if you think that you missed this detail due to poor documentation!
Hello Admin!
Besides the autoload() I slightly changed the JSReady class, allowing the developer to use a template engine, like smarty, passing the javascript code around as a variable.
main.php:
class JsReady
{
private $script;
/**
* Constructor.
*
* @param string $body
* @param boolean $print
* @return string
*/
function __construct($body, $print = true)
{
$prefix = “Ext.onReady(function()\n{\n”;
$suffix = “\n});\n”;
$this->script = $prefix . $body . $suffix;
if ($print)
print $this->script;
}
/**
* Returns the script
*
* @return string
*/
function getScript() {
return $this->script;
}
}
I successfully implemented a grid php class using the wrapper, now I’m struggling to implement insert/update/delete via Ajax callbacks. =)
In time: the docs are great, but what we (or maybe just me) really need are more examples =)
Is it possible to set a callback handler using ExtPHP?
I set a Ext_grid_EditorGridPanel_Config and added a ‘tbar’ attribute:
)
gridpanelconfigobject->tbar(array(’->’, array(’text’=>’Refresh’, ‘tooltip’ => ‘Refresh the grid’, ‘iconCls’=>’refresh’, ‘handler’=>’updateGrid̵
And the addRecord is rendered as a string. I could use a JsFunction() instead, but I noticed that the Javascript code does not create any variable to assign the instantiated classes. How can I call the reload() method of the datastore object?
Hi! Just in case someone find it useful.
That did the trick about the js variables. The $this->datastore[’name’] points to a object of the Ext.data.Store class:
—-
//creating js variables
JsWriter::write(’var ‘. $this->datastore[’name’] . ‘ = ‘);
$this->datastore[’object’]->jsrender();
JsWriter::write(”;”);
JsWriter::write(’var ‘. $this->panel[’name’] . ‘ = ‘);
$this->panel[’object’]->jsrender();
JsWriter::write(”;”);
//getting the javascript code
$js = new JsReady(JsWriter::get(), false);
$out = $js->getScript();
—-
Then, to set a callback, I just instantiated a JsFunction():
—-
‘handler’ => new JsFunction(null, “{$this->datastore[’name’]}.reload()” )
—-
Great wrapper!
Me again!
Found a bug on Ext.data.Record.php:
—-
static function create($o= null)
{
if(gettype($o)==’array̵
$o = JsWriter::JSON($o);
$o=JsWriter::JSON($o);
$out =
Great job !
I use it often now and I like it.
Just a problem now: The FormPanel doesn’t contain the config options of the basicForm class. In ext, formpanel extend panel BUT include the configuration option of the basicForm class (see the bold explaination in Ext formPanel doc). How could I fix that problem (or is there a better solution ?) ?
Guys, sorry for not replying earlier. A lot of your comments were in the ‘Possible spam, must validate manually’ basket. Not sure why.
@Seiti, I really appreciate your contribution. I wonder why the code you mention in comment #31 was created this way. I’ll check.
@pempem I believe that I am going to have to start adding some special cases to the converter, to handle these “special places” where Jack used his own magic tricks. In the meantime, your FormPanel configuration class could extend BasicForm’s config class but this sounds dirty. I have to check the code…
Some of you may be wondering “When are you going to release a more polished version?” and you are right to wonder.
I guess I am doing what a lot of other people have been doing lately…waiting to see what happens with ExtJS’ license.
What do you guys think? Are you using the library professionally? In an open-source project? Do you fear the license changes?