Building a Javascript Powered Website using YII


I am new to Yii and trying to understand if I want ot use Yii or not. I have programmed in Java for 12 years and am very very good with Java. I started looking at PHP as I am in the process of building a online business. However, I did not like what I saw but then I stumbled upon Yii and liked what I have seen so far.

So my question (perhaps has been answered before though could not find very clear examples).

  • I want to build my website using JavaScript library (JQuery, EXT-JS etc etc). The main architecture is that the backend (server code) is only used for performing logic on data and managing data. No HTML from PHP at all. Can someone point me to text on how to do this - book, forum posts, internet resources anything will help.

Main concern: I dont want to break my HTML designers code into components. That is additional work for me as I do not have them running Yii (they will never do this) and the only best way for me is to use the entie HTML that I get from the designer and add 2 lines of javascript library code (i.e. framework like JQuery and custom lib doing AJAX to server) and get going. This will help me to maxmimize my investment.

Of course there are some concerns around session hijacking etc that I have thought about in my acthiecture which I dont have a solution for as of now. The main constraint is that I like the MVC architecture of Yii, though I dont like the "V" to be in Yii / php files at all.

Thanks for your help in answering my post.

Well, it sounds like you understand most of it. You’ll be making AJAX calls, so your controller actions (which are urls) will have to return JSON or I suppose XML data. I’m guessing you’ll be going with JSON. The PHP function, json_encode, will become your friend. Just thinking out loud, but you’ll probably want to create json outputting methods in your models and call those from your controller actions.

As far as resources, anything that covers PHP JSON would apply along with the specifics of models and controllers in Yii which are covered in The Definitive Guide.