Using PHP interfaces in Codeigniter

Posted by John Stewart on Stack Overflow See other posts from Stack Overflow or by John Stewart
Published on 2010-05-16T14:12:26Z Indexed on 2010/05/16 14:20 UTC
Read the original article Hit count: 179

Filed under:
|
|
|

I am trying to find out how can I used PHP interfaces in my MVC design. I want to make sure that the design enforces an interface so that any new module would follow that.

For example:

<?php

interface BaseAPI {
     public function postMessage($msg);
}

class ServiceAPI implements BaseAPI {
     public function postMessage($msg) { return $msg; }
}

class Service_Two_API implements BaseAPI {
     public function postMessage($msg) { return "can't do this: ".$msg; }
}

?>

I want to do this in CI. Is it possible? how should I design it?

© Stack Overflow or respective owner

Related posts about php

Related posts about php5