タグ

DIとphpに関するkitokitokiのブックマーク (3)

  • Twittee: A Dependency Injection Container in a Tweet

    class Container { protected $s=array(); function __set($k, $c) { $this->s[$k]=$c; } function __get($k) { return $this->s[$k]($this); } } What is Twittee? Twittee is the smallest, and still useful, Dependency Injection Container in PHP; it is also probably one of the first public software to use the newest anonymous functions support of PHP 5.3. Packed in less than 140 characters, it fits in a twee

  • 簡単なDIコンテナ - Sooey

    簡単なDIコンテナ 最小のDIコンテナ in PHP – anatoo勉強記より。 DIコンテナがなにやら大仰なものとして勘違いされているような気がしたので、機能を極限まで削ぎ落とした最小のDIコンテナを書いた。 これにはAOPは当然ないし、設定ファイルなどもない。 30行ほどのコードでDIコンテナっぽい動きを示せているところは素晴らしいです。確かにDIコンテナにAOPは必須ではないし、設定ファイルもできればない方がいいですもんね。 ただ、「最初の取っ掛かり」ということで極限まで簡略化されたのでしょうが、異なるコンポーネント間のDependencyをInjectionできないものはDIコンテナではなくて単なるオブジェクトプールのような気がします。簡単なsetterインジェクションをする場合なら、こんな感じでしょうか。 これはこれで設計的にヘンなところが色々ありますが、このくらいのコードだと

  • What is Dependency Injection? |Articles - Fabien Potencier

    This article is part of a series on Dependency Injection in general and on a lightweight implementation of a Container in PHP in particular: Part 1: What is Dependency Injection? Part 2: Do you need a Dependency Injection Container? Part 3: Introduction to the Symfony Service Container Part 4: Symfony Service Container: Using a Builder to create Services Part 5: Symfony Service Container: Using XM

  • 1