タグ

関連タグで絞り込む (1)

タグの絞り込みを解除

PHPとDIに関するrryuのブックマーク (1)

  • DIとサービスロケータの違い

    DIとサービスロケータは、いずれもオブジェクトの構築と依存の解決という仕事を切り出すためのパターンです。ところで、この2つのパターンの違いを明確に説明できるでしょうか? Pimpleでシンプルに正しくDIを理解する のコードは以下のようになっていました。 <?php require_once '../vendor/pimple/pimple/lib/Pimple.php'; // インフラ interface MailerInterface { public function send($body); } class SendmailMailer implements MailerInterface { public function send($body) { } } // ドメイン class NewsletterTransfer { protected $mailer; public

    DIとサービスロケータの違い
    rryu
    rryu 2014/10/31
  • 1