Menu

Link

S2Container.PHP Project

% cat quickstart.php
<?php
require_once('S2Container.php');

class Action {
    public $service;
}

class Service {
    public $dao;
}

class Dao {
    private $pdo;
    public function setPdo(PDO $pdo) {
        $this->pdo = $pdo;
    }
}

s2component('PDO')->construct(function(){
    return new PDO('sqlite::memory:');
});

var_dump(s2get('Action'));

%
%
% php quickstart.php
object(Action)#36 (1) {
  ["service"]=>
  object(Service)#51 (1) {
    ["dao"]=>
    object(Dao)#67 (1) {
      ["pdo":"Dao":private]=>     
      object(PDO)#72 (0) {
      }
    }
  }
}
%

Download


Document


Environment

S2Container.PHP is tested on the following environment.

  • CentOS 5.2 : php-5.3.2