Wednesday, January 14, 2009

Making Cakephp and Shindig work together

So we decided to use Shindig for our web console widgets. There is lot of documentation on how to make shindig work as a virtualhost.

However, I didnt find complete documentation on how to make it work as a Alias (say www.domain.com/shindig/xxxx)
Where your Cakephp app runs at www.domain.com/

So basically, we have cakephp running as virtual host and our gadgets/widgets will be provided by shindig using the url www.domain.com/shindig/gadgets/ifr

Just few days ago, I read an interesting point in a performance article on Android code site - (paraphrasing) there are two phases of learning to developing on a new platform - first step is to make it work, second step is to make it work the right way.

So here is what I did and made it work - now you readers tell me how to make it work the right way.

I did svn co of Shindig in my downloads directory.
From there, I exported the following directories into vendors/shindig directory of my cake app.
- config
- features
- javascript
- php

So far so good.

In shindig/php/.htaccess file have the following line uncommented:
RewriteRule (.*) /shindig/index.php [L]

In shindig/php/config/container.php update as follows:
'web_prefix' => '/shindig',
'default_js_prefix' => '/shindig/gadgets/js/',
'default_iframe_prefix' => '/shindig/gadgets/ifr?',


In shidig/config/container.js, change all occurences of %host% with %host%/shindig. When I did it, there were 5 instances.

Now the shindig side is updated.

Next we need to tell Cakephp to ignore shindig urls. So, in your root .htaccess file
add
RewriteRule ^shindig/.*$ - [L]
Getting this to work took me a good part of the day. But hey, I now know how mod rewrite works, which I never bothered to learn till now.


Last part, we need to update the apache virtual host, so I added the following block:

Alias /shindig /dev/coolproduct/vendors/shindig/php
<Directory /dev/coolproduct/vendors/shindig/php>
</Directory>



Now, I put in a sample container and a widget, which I can load using:
http://local.domain.com/shindig/gadgets/files/coolappsamplecontainer/coolappsamplecontainer.html

3 comments:

Subin George said...

Hi Bro..
Really Good Work.
But you need more optimization.

Like you can't access vendor files out side you local machines even though you have create the alias

So Better, my suggestion is you simple move the shindig files to Web root

No more Modification is required
It will work fine.

The don't forget to remove the "shindig "Alias

Regards
Subin George P

Unknown said...

That was a nice article but would you please post more details about how you did the integration between both CakePHP and shindig, if you would do that then that would be really so nice from you, Thank you again

Altieres said...

Did you do something related to permission per user?