phpmef/phpmef

This package is abandoned and no longer maintained. No replacement package was suggested.

PHPMEF allows easy composition and extensibility in an application.

dev-master 2014-07-08 06:34 UTC

This package is not auto-updated.

Last update: 2020-01-20 09:34:35 UTC


README

PHPMEF is a PHP port of the .NET Managed Extensibility Framework, allowing easy composition and extensibility in an application using the Inversion of Control principle and 2 easy keywords: @export and @import.

Downloads

Latest download can be found under releases.

Hello, PHPMEF!

Here's a simple example on how PHPMEF can be used:


  class HelloWorld {
      /**
       * @import-many MessageToSay
       */
      public $Messages;
  
      public function sayIt() {
          echo implode(', ', $this->Messages);
      }
  }
  
  class Hello {
      /**
       * @export MessageToSay
       */
      public $HelloMessage = 'Hello';
  }
  
  class World {
      /**
       * @export MessageToSay
       */
      public $WorldMessage = 'World!';
  }
  
  $helloWorld = new HelloWorld();
  
  $compositionInitializer = new MEF_CompositionInitializer(new MEF_Container_Default());
  $compositionInitializer->satisfyImports($helloWorld);
  
  $helloWorld->sayIt(); // Hello, World!

Check the wiki for more information.