Kohana 3 and Waterspout integration
Inspired by [1] and [2] an idea came to integrate Kohana with Waterspout, to make add Kohana more powerful in the sence of websockets.
Actually there are two ways how to do that, depending on which of them should be main framework and which should be dependable. The first oprtion is convinient if you are going to use Kohana+Waterspout only as a WebSocket server. The second option is more convinient as you can use as separately Kohana and Waterspout for some controllers and for some controllers together.
Option I (Kohana is a main framework)
Actually we are going to convert Kohana into WebSocket server.
Implementation could be similar to Kohana + Zend Framework Web Services.
- We just include waterspout server into Kohana’s index.php
- Rename waterspout Controller class to something line ControllerWS and a variable $request to $requestws
- Add one more class to extension chain of Kohana Controller by extending ControllerWS.
- Execute as a daemon kohana’s index.php, like php –q kohana_path/index.php
Option II (Waterspout and Kohana work in parralel)
Here we are going to allow calls of Kohana controllers from Waterspout controllers.
For this we need:
- Make a copy of index.php from kohana root and name it for example waterspout.php, inside we will use also a copy of bootstrap.php, lets call it bootstrapwaterspout.php
Just change in the code last line of index.php file
require APPPATH.'bootstrapwaterspout'.EXT;
- Make a copy of bootstrap.php from kohana application folder and name it for example bootstrapwaterspout.php, place it in the same direcory where origional bootstrap was.
- Change bootstrapwaterspout.php in a way that just comment out last block
- In waterspout we also need some changes. As Waterspout and Kohana have some classes and variables with the same name, we should rename waterspout class Controller to for exapme ControllerWS, just do refactor in eclipse or find-replace. You Should also replace variable $request to $requestWS in the whole waterspout framework (not too much, some kind of ~10 replacements)
- In waterspout, I do not why we are starting to receive warnings, but line 229 should be also replaced in file /libs/ to the folowing code
* Execute the main request. A source of the URI can be passed, eg: $_SERVER['PATH_INFO'].
* If no source is specified, the URI will be automatically detected.
*/
//echo Request::instance()
//->execute()
//->send_headers()
//->response;
- We are done, just place this include in the place you would like to request kohana controllers or views, in our case
from
to
$this->remote_ip = $preg_result['ip'];
- We are done, just place this include in the place you would like to request kohana controllers or views (or even better into waterspout server.php), in our case
and feel free to request controllers or views via request factory like this
References
[1] – https://github.com/wp-kohana/wp-kohana
[2] – http://kohana-modules.com/modules/kerkness/wordpress-for-kohana










Hye,
I want to try this class, but i can’t dezip de file. Can you send me apr email?
Thank’s a lot
Reply
Hello Webmaster, I noticed that http://anton.vedeshin.com/articles/kohana-3-and-waterspout-integration is ranking pretty low on Google and has a low Google PageRank. Now the Google PageRank is how Google is able to see how relevant your webpage is compared to all the other webpages online, if you cannot rank high at the top of Google, then you will NOT get the traffic you need. Now usually trying to get to the top of Google costs hundreds if not thousands of dollars and very highly optimized targeted marketing campaigns that takes a team of experts months to achieve. However, we can show you how to get to the top of Google with no out of pocket expenses (free traffic), no stupid ninja tricks, no silly mind control techniques, and this will be all white hat with no blackhat software or tactics that could possibly land you on bad terms with Google and put you in the dreaded “Google Sandbox”. We’ll show you how to easily capture all the targeted traffic you need, for free, multiple ways to land fast (not months) first-page rankings in Google and other major search engines (Bing, Yahoo, Ask, etc), even show you strategies on how to earn daily commissions just try Ranking Top of Google, please check out our 5 minute video.
Reply