-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.php
50 lines (35 loc) · 1.33 KB
/
test.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
<?php
// app.php in your project's root directory
require_once __DIR__ . '/vendor/autoload.php';
use Cspray\Labrador\AbstractApplication;
use Cspray\Labrador\EnvironmentType;
use Cspray\Labrador\CoreApplicationObjectGraph;
use Cspray\Labrador\Engine;
use Cspray\Labrador\StandardEnvironment;
use Amp\Promise;
use Amp\Delayed;
use Amp\Log\StreamHandler;
use Monolog\Logger;
use function Amp\call;
use function Amp\ByteStream\getStdout;
class HelloWorldApplicationObjectGraph extends CoreApplicationObjectGraph {
public function wireObjectGraph() : \Auryn\Injector{
$injector = parent::wireObjectGraph();
// wire up your app's dependencies
return $injector;
}
}
class HelloWorldApplication extends AbstractApplication {
protected function doStart() : Promise {
return call(function() {
yield new Delayed(500); // just to show that we are running on the Loop
$this->logger->info('Hello Labrador!');
});
}
}
$environment = new StandardEnvironment(EnvironmentType::Development());
$logger = new Logger('labrador.hello-world', [new StreamHandler(getStdout())]);
$injector = (new HelloWorldApplicationObjectGraph($environment, $logger))->wireObjectGraph();
$app = $injector->make(HelloWorldApplication::class);
$engine = $injector->make(Engine::class);
$engine->run($app);