Class Plugins in PHP?

Posted by YuriKolovsky on Stack Overflow See other posts from Stack Overflow or by YuriKolovsky
Published on 2010-03-18T15:31:26Z Indexed on 2010/03/18 15:41 UTC
Read the original article Hit count: 333

Filed under:
|
|
|

i just got some more questions while learning PHP, does php implement any built in plugin system?

so the plugin would be able to change the behavior of the core component.

for example something like this works:

include 'core.class.php';
include 'plugin1.class.php';
include 'plugin2.class.php';
new plugin2;

where core.class.php contains

class core {
  public function coremethod1(){
    echo 'coremethod1';
  }
  public function coremethod2(){
    echo 'coremethod2';
  }
}

plugin1.class.php contains

class plugin1 extends core {
  public function coremethod1(){
    echo 'plugin1method1';
  }
}

plugin2.class.php contains

class plugin2 extends plugin1 {
  public function coremethod2(){
    echo 'plugin2method2';
  }
}

This would be ideal, if not for the problem that now the plugins are dependable on each other, and removing one of the plugins:

include 'core.class.php';
//include 'plugin1.class.php';
include 'plugin2.class.php';
new plugin2;

breaks the whole thing...

are there any proper methods to doing this? if there are not, them i might consider moving to a different langauge that supports this...

thanks for any help.

© Stack Overflow or respective owner

Related posts about php

Related posts about plugins