CakePHP Who's Online Plugin
Please Support:
CakePHP Online Plugin
Info:
- Version: 2.0
- Requirements: CakePHP 1.x/2.x
- Docs: CakePHP Online Plugin API
- Article: CakePHP Online Plugin Discussion and Examples
Watch:
Get it:
- Download Now
- git clone git://github.com/webtechnick/CakePHP-Online-Plugin
Wouldn't it be handy to see how many people are on your CakePHP app at any given time? Wouldn't it be nice to actually see where they currently are in your app? With this simple CakePHP plugin -- now you can
The result is at anytime you'll be able to see an accurate list of online, active, users as well as where they currently are on your site.
1) Copy the /online into your /app/plugins/online
2a) Run the online.sql into your database
2b) Run
3) You'll need to add a bit of code to your app_controller.php
//app_controller.php
Once you have the database in place and those few lines of code in your app_controller.php you'll now be tracking your site's users -- you spy you.
1) You can use the built in OnlineHelper::all() which will return you an associative array of all the online users cakePHP style.
2) You can use the requestAction() which will again return you an associative array of all the online users cakePHP style.
3) You can use the built in Element (You will need to style this heavily to fit your site)
Use whichever way you prefer. =)
As always, if you like the plugin, find a bug, or have a feature request -- post a comment.
If you use the plugin and want to help support it, please consider a small donation or just click an Ad a few times. ;)
Hope you find it useful,
Nick
Simple Concept...
The idea is simple; anytime someone visits your app a small database entry is created logging what their IP is and what they're currently looking at. As they browse around your app their online status updates to what they're currently looking at. The log is kept clean every 10 minutes that same someone hasn't browsed your app.The result is at anytime you'll be able to see an accurate list of online, active, users as well as where they currently are on your site.
Install
Installing is straight forward, just like any other plugin:1) Copy the /online into your /app/plugins/online
2a) Run the online.sql into your database
2b) Run
- cake schema run create -path plugins/online/config/sql -name online
Note: If you choose the 'cake schema' route, I highly suggest you convert your database engine to MEMORY as it will be faster to access/write than the default engine CakePHP gives all tables.
Note 2: If you choose 'cake schema' route, I suggest you change the 'ip' column to 'unsigned'
3) You'll need to add a bit of code to your app_controller.php
//app_controller.php
- function beforeRender(){
- $this->Online->update($this->here);
- }
Once you have the database in place and those few lines of code in your app_controller.php you'll now be tracking your site's users -- you spy you.
How do I see who's online?
Funny you should ask, I've provided a few ways for you to see who's online.1) You can use the built in OnlineHelper::all() which will return you an associative array of all the online users cakePHP style.
- //Some Controller
- //Some view
- echo debug($online->all());
2) You can use the requestAction() which will again return you an associative array of all the online users cakePHP style.
- //Some view
- echo debug($this->requestAction('/online/onlines'));
3) You can use the built in Element (You will need to style this heavily to fit your site)
Use whichever way you prefer. =)
Enjoy!
That's it, enjoy seeing who's online and what they're currently looking at.As always, if you like the plugin, find a bug, or have a feature request -- post a comment.
If you use the plugin and want to help support it, please consider a small donation or just click an Ad a few times. ;)
Hope you find it useful,
Nick