PDA

View Full Version : PHP Dynamic Ext Bindings



chalu
3 Jun 2008, 9:11 PM
Is anyone aware of the PHP-Ext google code project, has anyone used it. Generating dynamic Js objects can prove to be a huge time saver especially in big projects, but I have never been a fan of outputting the raw Js code from a server process. PHP-Ext google code project (http://code.google.com/p/php-ext/)
Project Website (http://php-ext.quimera-solutions.com/)

danh2000
4 Jun 2008, 12:01 AM
Hi,

I'm a big fan of PHP so checked this out previously, and again after seeing your post - The current release has improved and the coding style is much better, but I still (personally) don't see the point.

If you take a look at some example code (below), where is the benefit - it's simply taking the client code, moving it to the server, and (in my opinion) making it more verbose - if it automatically generated the views based on your domain model, I could see why some people would be interested, but you have to write the code somewhere, so I'd prefer to stick to the client and use the natural language of the library.

I don't want to offend the creator or the work that's been done - what he's/she's done seems good, so if it floats your boat then go for it, but it isn't for me.

Example Code:



$store = new PhpExt_Data_SimpleStore();
$store->addField(new PhpExt_Data_FieldConfigObject("company"));
$store->addField(new PhpExt_Data_FieldConfigObject("price",null,"float"));
$store->addField(new PhpExt_Data_FieldConfigObject("change",null,"float"));
$store->addField(new PhpExt_Data_FieldConfigObject("pctChange",null,"float"));
$store->addField(new PhpExt_Data_FieldConfigObject("lastChange",null,"date","n/j h:ia"));

// ColumnModel
$colModel = new PhpExt_Grid_ColumnModel();
$colModel->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Company","company","company",160, null, null, true, false))->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Price","price",null,75,null,PhpExt_Javascript::variable("Ext.util.Format.usMoney"), null, true))
->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Change","change",null,75,null,PhpExt_Javascript::variable('change'), null, true))
->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("% Change","pctChange",null,75,null,PhpExt_Javascript::variable('pctChange'), null, true))
->addColumn(PhpExt_Grid_ColumnConfigObject::createColumn("Last Updated","lastChange",null,85,null,PhpExt_Javascript::variable("Ext.util.Format.dateRenderer('m/d/Y')"), null, true));

// Grid
$grid = new PhpExt_Grid_GridPanel();
$grid->setStore($store)
->setColumnModel($colModel)
->setStripeRows(true)
->setAutoExpandColumn("company")
->setHeight(350)
->setWidth(600)
->setTitle("Array Grid");

...

chalu
4 Jun 2008, 2:11 AM
I commend the effort that has gone into that project, but for me I saw it as an overkill trying to do all the client side native stuff in a server process. I would have been bought out if it concentrated maybe on things that change like a Grid's coloumn model, a form's fields specs or a wizard's pages specs. allowing you build say the column model of a grid based on your domain model and other things like say priviledges of the user trying to use the grid at that time. I am still looking at it, I may create a subset of it into another project to suite what I've just described.