-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
66 lines (48 loc) · 1.08 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
require 'Container.php';
/**
* Usage
*/
class User {
public $db;
public function __construct(Db $db, $config = 'NULL', Cache $cache)
{
$this->db = $db;
echo "User with config {$config} was constructed <br/>";
}
public function register($name) {
$this->db->execute("INSERT INTO user SET name={$name}");
}
}
class DB {
public function __construct(Config $config) {
}
public function execute($sql) {
echo "{$sql} <br/>";
}
}
class Config {
public function __construct(Env $env, Model $model) {
echo 'Config DB is ready ..<br/>';
}
}
class Model {
public function __construct() {
echo 'Model is ready <br/>';
}
}
class Env {
public function __construct() {
echo 'Env is ready ..<br/>';
}
}
class Cache {
public function __construct() {
echo 'Cache is ready .. <br/>';
}
}
$container = new Container;
$user = $container->resolve('User');
$user->register('Oriza');