1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Portiere\WebServer; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class Vhost. |
7
|
|
|
* |
8
|
|
|
* Contains all the information a virtual host needs |
9
|
|
|
* |
10
|
|
|
* @author Ignacio Velazquez <[email protected]> |
11
|
|
|
*/ |
12
|
|
|
class Vhost implements VhostInterface |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* @var string Development environment |
16
|
|
|
*/ |
17
|
|
|
const ENV_DEV = 'dev'; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @var string Production environment |
21
|
|
|
*/ |
22
|
|
|
const ENV_PROD = 'prod'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
protected $filename; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
protected $serverName; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var string |
36
|
|
|
*/ |
37
|
|
|
protected $documentRoot; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
protected $errorLogFilename; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
protected $accessLogFilename; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var string |
51
|
|
|
*/ |
52
|
|
|
protected $env; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param string $filename |
56
|
|
|
*/ |
57
|
2 |
|
public function __construct($filename) |
58
|
|
|
{ |
59
|
2 |
|
$this->filename = $filename; |
60
|
2 |
|
$this->errorLogFilename = $this->filename.'.error.log'; |
61
|
2 |
|
$this->accessLogFilename = $this->filename.'.access.log'; |
62
|
2 |
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return string |
66
|
|
|
*/ |
67
|
2 |
|
public function getFilename() |
68
|
|
|
{ |
69
|
2 |
|
return $this->filename; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param string $filename |
74
|
|
|
* |
75
|
|
|
* @return Vhost |
76
|
|
|
*/ |
77
|
|
|
public function setFilename($filename) |
78
|
|
|
{ |
79
|
|
|
$this->filename = $filename; |
80
|
|
|
|
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @return string |
86
|
|
|
*/ |
87
|
|
|
public function getServerName() |
88
|
|
|
{ |
89
|
|
|
return $this->serverName; |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @param string $serverName |
94
|
|
|
* |
95
|
|
|
* @return Vhost |
96
|
|
|
*/ |
97
|
|
|
public function setServerName($serverName) |
98
|
|
|
{ |
99
|
|
|
$this->serverName = $serverName; |
100
|
|
|
|
101
|
|
|
return $this; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return string |
106
|
|
|
*/ |
107
|
|
|
public function getDocumentRoot() |
108
|
|
|
{ |
109
|
|
|
return $this->documentRoot; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @param string $documentRoot |
114
|
|
|
* |
115
|
|
|
* @return Vhost |
116
|
|
|
*/ |
117
|
|
|
public function setDocumentRoot($documentRoot) |
118
|
|
|
{ |
119
|
|
|
$this->documentRoot = $documentRoot; |
120
|
|
|
|
121
|
|
|
return $this; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
/** |
125
|
|
|
* @return string |
126
|
|
|
*/ |
127
|
|
|
public function getErrorLogFilename() |
128
|
|
|
{ |
129
|
|
|
return $this->errorLogFilename; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
/** |
133
|
|
|
* @return string |
134
|
|
|
*/ |
135
|
|
|
public function getAccessLogFilename() |
136
|
|
|
{ |
137
|
|
|
return $this->accessLogFilename; |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @return string |
142
|
|
|
*/ |
143
|
|
|
public function getEnv() |
144
|
|
|
{ |
145
|
|
|
return $this->env; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
/** |
149
|
|
|
* @param string $env |
150
|
|
|
* |
151
|
|
|
* @return Vhost |
152
|
|
|
*/ |
153
|
|
|
public function setEnv($env) |
154
|
|
|
{ |
155
|
|
|
if (null === $env) { |
156
|
|
|
return $this; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
$this->env = $env; |
160
|
|
|
|
161
|
|
|
return $this; |
162
|
|
|
} |
163
|
|
|
} |
164
|
|
|
|