Sabel DIContainer

Sabel DIContainerでannotationによるインジェクション設定を追加。

<?php

class TargetClass
{
  /**
   * @injection Profile
   */
  public function setProfileMethod($profile)
  {
  }
}

interface Profile
{
}

class ProfileImpl implements Profile
{
}

class DIConfig extends Sabel_Container_Injection
{
  public function configure()
  {
    $this->bind("Profile")->to("ProfileImpl");
  }
}

$target = load("TargetClass");

?>

というコードで、依存を注入できる。