ååã®ã¨ã³ããªã®ç¶ãã ãã®è¨äºã§ã¯ååã®ã¨ã³ããªã§æ¸ããDIã³ã³ããã使ã£ã¦ã¯ã©ã¹éãççµåã«ããä¾ãæ¸ãã ã¯ã©ã¹éãççµåã«ããã¨è¨ã£ã¦ããã¯ã©ã¹ã®å é¨ã§ä»ã®ã¯ã©ã¹ã«ä¾åãã¦ããã®ã§ã¯DIã³ã³ãããã©ã使ããã¨ççµåã«ã¯ãªããªãã 以ä¸ã®ã³ã¼ãããããLoggerã¯ã©ã¹å é¨ã«LogWriterã¯ã©ã¹ã¸ã®ä¾åãæ±ãã¦ããã <?php // ããããåç´ãªãã¬ã¼ class Logger { protected $writer; function __construct() { // LogWriterã¯ã©ã¹ããã¼ãã³ã¼ãã£ã³ã°ããã¦ããï¼ $this->writer = new LogWriter; } function debug($msg) { $this->writer->write('[debug]' . date('c') . ' '. $msg . PHP_EOL); }
{{#tags}}- {{label}}
{{/tags}}