Wednesday, November 15th, 2006

Tigermouse PHP/Ajax Framework

Category: PHP

<>p>Michal Slaby has created a new PHP/Ajax framework called Tigermouse.

Tigermouse is an object-oriented, event driven, MVC architecture based framework. Its goal is to take care of View and Controller part of the application, but there is also a very basic support for your Model. It encapsulates Javacript callbacks so you don’t have to write your own Javascript functions (unless you really want to).

Tigermouse abstracts out XMLHttpRequest and Javascript callbacks so you don’t play with them directly, and have no need to mix Javascript and PHP. The decision on which callback to call is being made at the server side instead of client side, after, not before you know the result of server side processing. There is also no function registering for binding PHP and Javascript functions together. Instead, you can call any public method you wish using path-like strings.

Example

Template

  1. <table id="{$id}">
  2. <tr>
  3.   <td>login:</td>
  4.   <td>{$login}</td>
  5. </tr>
  6. <tr>
  7.   <td>password:</td>
  8.   <td>{$passwd}</td>
  9. </tr>
  10. <tr>
  11.   <td colspan="2">{$ok}</td>
  12. </tr>
  13. </table>

Controller

  1. < ?php
  2. class MainCtrl extends Ctrl {
  3.  
  4.   public function show() {
  5.     $f = new Form('loginForm');
  6.     $f->template = 'app/LoginForm.tpl';
  7.  
  8.     $l = new Input('login');
  9.     $p = new Input('passwd');
  10.     $ok = new Button('ok');
  11.     $ok->text = 'Login';
  12.  
  13.     $f->add($l);
  14.     $f->add($p);
  15.     $f->add($ok);
  16.     $ok->addListener('onClick', 'LoginCtrl/auth', $f->valueReader());
  17.  
  18.     return $f;
  19.   }
  20.  
  21. }
  22. ?>
  23.  
  24. < ?php
  25. class LoginCtrl extends Ctrl {
  26.  
  27.   public function auth(FormContext $cx) {
  28.     $f = ActionService::execAction('MainCtrl/show');
  29.  
  30.     if ($cx->login) {
  31.       $this->response->eval($f['login']->errorMessage("You do have name, don't you?"));
  32.       return;
  33.     }
  34.  
  35.     $l = new Label('loginForm');
  36.     $l->text = "Hello {$cx->login}. I see you password is {$cx->passwd}. That's nice.";
  37.     return $l;
  38.   }
  39.  
  40.   public function show() { }
  41.  
  42. }
  43. ?>

Related Content:

  • Ajax Learning Guide
    Are you a Web developer? The time has come to rethink your entire approach to developing Web applications. Find out about the Ajax approach...
  • Ajax Learning Guide
    Chances are, you've been doing JavaScript and XML developer work in Lotus Domino for quite some time. This old/new approach is causing quite a stir in...

Posted by Dion Almaer at 6:44 am
4 Comments

+++--
3.5 rating from 28 votes

4 Comments »

Comments feed TrackBack URI

zx

Comment by \\\\\\\\\\ — November 16, 2006

asldkjfas

Comment by zxcv — November 29, 2006

Well Tigermouse Proyect is goin up. new version in http://sourceforge.net/projects/tigermouse/ is able. Many example in my web page http://pablim.homelinux.com

Comment by Pablim — March 3, 2007

I’m trying to learn Tigermouse and i want to teste your example, but…. i’m using microsoft windows and i don’t know how to setup it and how to integrate it with php. could you tell me how? i’v tried at Tigermouse site’s but i haven’t found.

Comment by Milton — October 27, 2007

Leave a comment

You must be logged in to post a comment.