Friday, October 28, 2011

Abandoning Jquery and Server-Generated HTML, moving to ExtJS + Yii backend

Our team wasted far too long trying to get our web app working with jQuery. Finally we discovered the joys of ExtJS 4, and are moving all development there.

Still using Yii as the backend for its nice models and controllers, as well as RBAC.


  1. will you provide some examples? thanks

  2. Why, whats wrong with jQuery? (vs ExtJS)

  3. @Jeroen: If you're programming Web *applications* and not just Web *sites*, then you will immediately understand the power of ExtJS. I have developed in both, and I can assure you that the maturity of an integrated professional library of widgets simply doesn't exist in the jQuery world. Instead, you have to resort to using different plug-ins for every single task (e.g. jqGrid, jsTree, validation, autonumeric, etc.) and integrating those becomes a nightmare, not to mention solving the bugs of plugins barely supported by lone developers.

    @Neil: Assuming you are not using ext4yii, it would be very interesting to post your setup with Yii and ExtJS, i.e. directory structure, composition of views and controllers, etc.

  4. Have you looked at jQuery UI?

  5. I came across this because I am interested in the power of extjs with Yii.

    Do you use the Yii controllers and models returning JSON to the ExtJs app?
    Do you use the partial views from Yii at all?
    Do you store the data to MySQL?
    Seems like ExtJs is a MVC itself. Is Yii and ExtJs together better in your opinion?

    Can you give me some idea as to what you found was the best setup? And in a nutshell, how does a pure Yii application differ from a Yii & ExtJs application?

    Thanks for any experiences you can share.

  6. @mark and @anonymous

    in my current project, we are using yii controllers and models, with no views (well, just one)

    ext sends json to a yii controller, which decodes it and loads it model(s). do some server-side validation, save to the mysql db

    ext also gets data from yii controllers, which queries db, puts the model and relations into an array and encodes as json

    ext is unaware of any many-many relationships in the db, and assumes they are has-many

    ext 4 does mvc, but that is all client mvc. still need to do server-side validation, where yii helps out.


  7. Niel,

    Thanks for the response. I had envisioned Yii and ExtJs working as you stated. That validates my thought process and gives me more confidence to integrate them both now.

    Can you elaborate on "ext is unaware of any many-many relationships in the db, and assumes they are has-many"?

  8. @mark: ext doesn't support manymany. Also, you probably don't want to worry about that on the client anyway. For example, We would send a blog posting + its tags to the client in one response. Client might add a tag, send the posting + all tags to server to update, then server figures out how to save tags to db. Essentially all manymany, hasone, and hasmany relationships are hasmany in ext (hasone is coming in 4.13)

  9. @Neil: Thanks again. One last question (for now). Are you using ExtJs solely as the view without business logic (controller) and model?

  10. @mark, we are using ext models, views and controllers. the view is just the javascript definition of the form/page, with no logic. the model is almost identical to a yii model (they are autogenerated), and the controller handles events on the ext views.

    the yii controllers are responsible for inputting and outputting json, server-side validation, and reading/writing to the database

    some of the application logic is on the client side, where performance is important. some is on the server side, where security is important

  11. correction, the yii controllers don't read/write from the db, the models, do, but the controllers use the models to read/write to db

  12. Great. Thanks Neil. I'd love to see this app you have!

    I'm planning on writing a desktop like app for my own business. On the surface, a fairly simple CRM but with enough uniqueness and industry oddities to build it from scratch.

    I can start by using small functions in my new app. Once I learn the be efficient at ExtJs and Yii and ....everything to build a simple application, I will have the skills to replace the existing antiquated VB app (without source) I bought. I'll be reading your blog.

    Thanks much.

  13. @mark Sounds good!

    Yii has a few issues you will want to tackle upfront such as writing related records to db automatically. The advanced ar behavior extension should help. You will also need to write a function to write json for relations.

    I would get to know how gii works and then use gii to write your ext mvcs in addition to yii's mvcs

    Ext 4.1 has some bug fixes and performance improvements and should be avail in a few weeks.

    Also check out Feng open source proj man tool to get some ideas on using php and ext together

  14. Your blog open my eyes to bring together Yii and ExtJS.
    Thanks a lot @Neil.

  15. ExtJS needs an overhaul of the general look and feel. It looks too much like Windows3.11 to me!