Ext4Yii, bridging PHP and JavaScript frameworks together
Ext JS
Ext JS is a (client-side) JavaScript library created for coding Rich Internet Applications. Nowadays no one uses bare JavaScript, without an abstraction layer over the browser JavaScript implementation. Along with JQuery, Dojo, MooTools and many others, Ext JS provides JavaScript developers with a reusable toolset for modifying the DOM, building form controls, or widgets like grids, tab panels and trees.
There has been some hype lately on Ext JS being renamed to Sencha, but it was a rebranding of the company behind this product, which proposes other libraries like Raphael (SVG-related). Ext JS is still available as a standalone product on Sencha’s website. Ext JS is released for free with its open source license adapt to other open source applications, but also as a commercial product, for commercial use.
Yii framework
Yii Web Programming Framework is a PHP 5 framework, mainly inspired by Prado. The goals of Yii are striving for high performance, achieved by simplicity of the design, and very loose coupling between the various components. Some of the features of Yii include the classic MVC implementation, database access infrastructure, and support for theming, caching and localization.
Yii is released under the BSD license, like Zend Framework, so there are no limitations to its use in open source or commercial projects.
Ext4Yii
Ext4Yii is essentially a bridge between these two projects, which aims to integrate Ext JS as an extension for Yii.
Ext4Yii is implemented as a templating system, which consumes XML models where you define widget elements like buttons or handlers (in embedded JavaScript code which can take advantage of Ext-powered methods and objects).
When using the provided ExtController as the superclass of the Yii application’s SiteController, the XML models are readily integrated and instantiated as Ext JS objects, without the need to include lots of .js files and event hooks.
In the Ext4Yii documentation, there are various examples of bootstrapping Ext JS widgets using these higher-level models, which deal with layout elements and forms. There are more advanced features included like AjaxMethods, which allows to call a registered PHP function via AJAX from the client side.
Learning a new modeling language can be complex, especially with verbose XML. Fortunately, there is a bundled plug-in for the NetBeans IDE which provides code completion for Ext4Yii. Even if you’re not a fan of IDEs, they sometimes are very handy in providing a rapid solution to bootstrap new tools like Ext4Yii.
Conclusion
PHP frameworks have been one of the most powerful innovations in the PHP landscape in the last years, and bridging them together with a JavaScript solution is important for being able to provide RIA behavior out of the box. There are similar successful solutions available on the web, like sfJqueryPlugin or Zend_Dojo, which prove that the concept of leveraging a JavaScript library into a PHP framework is an integration worth considering.
Leave a comment
Use the form below to leave a comment:
Responses and Pingbacks
July 15th, 2010 at 10:57 am
Here I was having a nice breakfast and you go write this article. I threw up in my mouth, twice. Thanks.
July 15th, 2010 at 6:35 pm
As seen in the May issue of php|architect, http://www.phparch.com/magazine/2010/may/, the NOLOH PHP Framework also bridges this gap, but does so in a much more PHP centric manner. Rather than shoe-horning Yii into ExtJS, with all the related Ext paradigms, NOLOH allows you to simply work in PHP completely, on the server, and forget the need to interact between the client or server, or think in Ext,or Ext XML, or think in something other than PHP/NOLOH.
Furthermore, you get the benefits of a true server-side framework in that any client components and the code related to them are only used and sent on-demand, as needed, thus allowing for a consistently fast and lightweight experience, without sacrificing any functionality.
The PHP community must be very confused with things like Ext4Yii. Why should a PHP developer need to communicate with a PHP function from the client, why should they be working in the client at all? Why are they writing the majority application in Ext XML, and hooks within script tags? It’s completely unnecessary, we should be embracing and furthering PHP and developing apps within it, rather that distancing ourselves from it.
This is what we believe at NOLOH anyway.
July 16th, 2010 at 4:48 am
Ext4Yii is simply an *extension for the Yii framework”. It is a plug-in that provides ExtJS functionality by parsing templates.
NOLOH is an *all in one framework* trying solve everything on the server, with its own components and widgets. (like PHP PRADO or ASP.NET)
The wealth of the ExtJS controls just cannot be compared to NOLOH.
July 16th, 2010 at 2:15 pm
Gevik, I understand that Ext4Yii is an extension of the Yii framework. My general criticism was that within the plug-in, you’re not doing any PHP, thus creating another layer of stuff that one needs to learn. If you read the Ext4Yii documentation, you end up writing most of your apps in XML, and script hooks. If you look at the documentation you see little to no PHP.
It also seems that you have no idea what you’re talking about in regard to your comments about NOLOH. If you were to actually USE NOLOH, which I don’t think you ever have, since we see no sign-up by your name. You would see that you can use ANY 3rd party Widget or Script with NO modification, besides whatever comes bundled, thus making the available options significantly larger than the wealth of Controls in just ExtJS. You can see one example of this in the 3rd party part of our Confoo screencast http://www.youtube.com/phpframework#p/u/7/fkmepX5fjEE.
Before you bundle NOLOH into PRADO, or ASP.NET in a public forum, maybe you should take the time to actually explore the tool you’re talking about. My post was a comment on the bridging of the blog post, and not a criticism or oversimplification of ExtJS or Ext4Yii. However, you decided to do the opposite.
Before I made my comment about Ext4Yii, I spent a significant amount of time browsing the documentation, reading the site, and downloading and playing with samples. It’s obvious that you didn’t take the same due diligence with your post.
July 16th, 2010 at 4:03 pm
Asher, I think we started off on the wrong foot here. By no means I wanted to take a shot at your product. I actually did spend some time to watch your new videos about NOLOH and got a fairly good idea about what it does. If this was six years ago I would have turned my entire programming team sailing with NOLOH. I also did explore your examples available on the website.
In my comment I addressed that NOLOH, like *other server-side frameworks* has its own set of widgets and controls. True or not?
In Ext4Yii your are creating most of your *views* in XML templates, that is true. That is what Ext4Yii is. This means that you have to be familiar with its syntax and also know how ExtJS works.
But the same goes with NOLOH too. One still has to learn NOLOH API to be able to create an app with it. Isn’t this *just another layer* then?
All in all Ext4Yii and NOLOH are very very different frameworks and cannot be compared as you did in you comment.
July 16th, 2010 at 5:31 pm
Gevik, I agree that we got started off on the wrong foot, and appreciate your kind words. I apologize if I was my tone was a bit harsh.
Indeed, NOLOH does have it’s own set of widgets and Controls, but what I was trying to get across in the previous post is that you’re not limited by that at all. NOLOH is more about the core, than the Controls than it provides, since it’s trivial to create your own Controls, or use 3rd party widgets.
I would argue that with NOLOH there is no additional layer, since most everything you do is in NOLOH, unike Ext4Yii, where the developer must work in Yii, then Ext XML, and possibly JavaScript.
In any event, I agree that Ext4Yii and NOLOH are very different frameworks, and that comparing them doesn’t serve either justice. My only aim was to point out that NOLOH too can bridge the gap between JavaScript and PHP, while allowing the developer to spend more of their time in a single mindset.
P.S. In your previous post you accidentally posted as Asher.
July 20th, 2010 at 9:30 am
http://www.ext4yii.com/index.php/site/purchase
Price per year
$299 $1046 $2290 contact us?
In variety of amazing opensource ui sdk ,,this option is very expensive even doest have trial ,
I am seeing more good future of sproutcore with as it allows any server side technologies
July 20th, 2010 at 3:47 pm
Sajid, while I don’t represent the views of Ext4Yii, I can speak from a knowledgeable point of view. They have multiple options, including a free open source option. However, this option is of course limited to open source projects, similarly the ExtJS library they’re bound too has a similar provision.
As one of the co-founder of NOLOH, a comprehensive PHP framework I find it odd that you’re against paying for software for commercial purposes. Software takes a significant amount of time and money to develop, and support. It’s unfair to suggest that everybody should make their software free, while you may charge for your services and products built with it.
Of course, if you are developing an open source project many tools, including NOLOH and Ext4Yii provide free licenses to use with your open source projects.
Personally I believe that’s a fair compromise. We all need to eat, and unlike many software projects, your local market won’t provide you with the necessary sustenance free of charge, whether it’s for personal or commercial consumption. All that they ask for is compensation if you’re planning to use it commercially.
July 20th, 2010 at 7:30 pm
Sajid, If you are developing an open-source application then the Ext4Yii framework, just like the ExtJS framework is free of charge as long as you comply to the terms that are stated in the GPL3 license.
However, If you are planning to utilize the framework commercially then the license fees are a small amount to pay.
Creating software is not easy and takes a lot of research and effort. Products like Ext4Yii and NOLOH are no exception to that. Imagine you wanting to create a framework with the exact same functionality and the quality of those products. How many hundreds if not thousands of man hours you have to invest to get there?
July 21st, 2010 at 10:25 am
I’m trying to open forum but sometimes there are no images on it 🙁
July 22nd, 2010 at 6:18 am
How many times have we heard about security issues in PHP applications stemming from unescaped GET and POST parameters? Proper escaping of input is a perennial problem with web development in general, and for whatever reason PHP seems to have had more than its fair share of bad publicity on this front
July 29th, 2010 at 9:00 am
The ext4yii licence says
“Develop software for use only within your organization or company, under the following (GPL applied) terms:
The software must not be accessible by any persons outside your organization or company, and
The software must be developed exclusively by your organization “on-site”. Transferring a copy of your software to another organization or individual “off-site”, including contractors, is considered distribution.”
Hmmm… so i cant share my open source project with anybody???
August 6th, 2010 at 8:13 pm
[…] Source: http://www.phparch.com/2010/07/15/ext4yii-bridging-php-and-javascript-frameworks-together/ […]
November 23rd, 2010 at 4:49 am
Yes, you right. The information in this blog is really a appreciable. I would really like to say that the knowledge you have about this is quit impressing. But the main thing here is the way to present the information, and you have done it very nicely. Great work and love to visit on your blog again and again. Keep posting nice information.