Micro.php
7.05 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<?php
namespace Phalcon\Mvc {
/**
* Phalcon\Mvc\Micro
*
* With Phalcon you can create "Micro-Framework like" applications. By doing this, you only need to
* write a minimal amount of code to create a PHP application. Micro applications are suitable
* to small applications, APIs and prototypes in a practical way.
*
*<code>
*
* $app = new Phalcon\Mvc\Micro();
*
* $app->get('/say/welcome/{name}', function ($name) {
* echo "<h1>Welcome $name!</h1>";
* });
*
* $app->handle();
*
*</code>
*/
class Micro extends \Phalcon\DI\Injectable implements \Phalcon\Events\EventsAwareInterface, \Phalcon\DI\InjectionAwareInterface, \ArrayAccess {
protected $_dependencyInjector;
protected $_handlers;
protected $_router;
protected $_stopped;
protected $_notFoundHandler;
protected $_activeHandler;
protected $_beforeHandlers;
protected $_afterHandlers;
protected $_finishHandlers;
protected $_returnedValue;
/**
* \Phalcon\Mvc\Micro constructor
*
* @param \Phalcon\DiInterface $dependencyInjector
*/
public function __construct($dependencyInjector=null){ }
/**
* Sets the DependencyInjector container
*
* @param \Phalcon\DiInterface $dependencyInjector
*/
public function setDI($dependencyInjector){ }
/**
* Maps a route to a handler without any HTTP method constraint
*
* @param string $routePattern
* @param callable $handler
* @return \Phalcon\Mvc\Router\RouteInterface
*/
public function map($routePattern, $handler){ }
/**
* Maps a route to a handler that only matches if the HTTP method is GET
*
* @param string $routePattern
* @param callable $handler
* @return \Phalcon\Mvc\Router\RouteInterface
*/
public function get($routePattern, $handler){ }
/**
* Maps a route to a handler that only matches if the HTTP method is POST
*
* @param string $routePattern
* @param callable $handler
* @return \Phalcon\Mvc\Router\RouteInterface
*/
public function post($routePattern, $handler){ }
/**
* Maps a route to a handler that only matches if the HTTP method is PUT
*
* @param string $routePattern
* @param callable $handler
* @return \Phalcon\Mvc\Router\RouteInterface
*/
public function put($routePattern, $handler){ }
/**
* Maps a route to a handler that only matches if the HTTP method is PATCH
*
* @param string $routePattern
* @param callable $handler
* @return \Phalcon\Mvc\Router\RouteInterface
*/
public function patch($routePattern, $handler){ }
/**
* Maps a route to a handler that only matches if the HTTP method is HEAD
*
* @param string $routePattern
* @param callable $handler
* @return \Phalcon\Mvc\Router\RouteInterface
*/
public function head($routePattern, $handler){ }
/**
* Maps a route to a handler that only matches if the HTTP method is DELETE
*
* @param string $routePattern
* @param callable $handler
* @return \Phalcon\Mvc\Router\RouteInterface
*/
public function delete($routePattern, $handler){ }
/**
* Maps a route to a handler that only matches if the HTTP method is OPTIONS
*
* @param string $routePattern
* @param callable $handler
* @return \Phalcon\Mvc\Router\RouteInterface
*/
public function options($routePattern, $handler){ }
/**
* Mounts a collection of handlers
*
* @param \Phalcon\Mvc\Collection $collection
* @return \Phalcon\Mvc\Micro
*/
public function mount($collection){ }
/**
* Sets a handler that will be called when the router doesn't match any of the defined routes
*
* @param callable $handler
* @return \Phalcon\Mvc\Micro
*/
public function notFound($handler){ }
/**
* Returns the internal router used by the application
*
* @return \Phalcon\Mvc\RouterInterface
*/
public function getRouter(){ }
/**
* Sets a service from the DI
*
* @param string $serviceName
* @param mixed $definition
* @param boolean $shared
* @return \Phalcon\DI\ServiceInterface
*/
public function setService($serviceName, $definition, $shared=null){ }
/**
* Checks if a service is registered in the DI
*
* @param string $serviceName
* @return boolean
*/
public function hasService($serviceName){ }
/**
* Obtains a service from the DI
*
* @param string $serviceName
* @return object
*/
public function getService($serviceName){ }
/**
* Obtains a shared service from the DI
*
* @param string $serviceName
* @return mixed
*/
public function getSharedService($serviceName){ }
/**
* Handle the whole request
*
* @param string $uri
* @return mixed
*/
public function handle($uri=null){ }
/**
* Stops the middleware execution avoiding than other middlewares be executed
*/
public function stop(){ }
/**
* Sets externally the handler that must be called by the matched route
*
* @param callable $activeHandler
*/
public function setActiveHandler($activeHandler){ }
/**
* Return the handler that will be called for the matched route
*
* @return callable
*/
public function getActiveHandler(){ }
/**
* Returns the value returned by the executed handler
*
* @return mixed
*/
public function getReturnedValue(){ }
/**
* Check if a service is registered in the internal services container using the array syntax.
* Alias for \Phalcon\Mvc\Micro::hasService()
*
* @param string $alias
* @return boolean
*/
public function offsetExists($serviceName){ }
/**
* Allows to register a shared service in the internal services container using the array syntax.
* Alias for \Phalcon\Mvc\Micro::setService()
*
*<code>
* $app['request'] = new \Phalcon\Http\Request();
*</code>
*
* @param string $alias
* @param mixed $definition
*/
public function offsetSet($serviceName, $definition, $shared=null){ }
/**
* Allows to obtain a shared service in the internal services container using the array syntax.
* Alias for \Phalcon\Mvc\Micro::getService()
*
*<code>
* var_dump($di['request']);
*</code>
*
* @param string $alias
* @return mixed
*/
public function offsetGet($serviceName){ }
/**
* Removes a service from the internal services container using the array syntax
*
* @param string $alias
* @todo Not implemented
*/
public function offsetUnset($alias){ }
/**
* Appends a before middleware to be called before execute the route
*
* @param callable $handler
* @return \Phalcon\Mvc\Micro
*/
public function before($handler){ }
/**
* Appends an 'after' middleware to be called after execute the route
*
* @param callable $handler
* @return \Phalcon\Mvc\Micro
*/
public function after($handler){ }
/**
* Appends a 'finish' middleware to be called when the request is finished
*
* @param callable $handler
* @return \Phalcon\Mvc\Micro
*/
public function finish($handler){ }
/**
* Returns the internal handlers attached to the application
*
* @return array
*/
public function getHandlers(){ }
}
}