-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.php
30 lines (24 loc) · 935 Bytes
/
main.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
<?php
namespace MyVendor\Greeting;
use BEAR\Resource\Module\ResourceModule;
use BEAR\Resource\ResourceInterface;
use BEARSunday\Thrift\ImportThriftAppModule;
use BEARSunday\Thrift\ThriftApp;
use Ray\Di\AbstractModule;
use Ray\Di\Injector;
use function dirname;
require dirname(__DIR__, 2) . '/vendor/autoload.php';
require __DIR__ . '/vendor/autoload.php';
$injector = new Injector(new class() extends AbstractModule
{
protected function configure(): void
{
$this->install(new ResourceModule('MyVendor\Greeting'));
$this->override(new ImportThriftAppModule([
new ThriftApp('sekai', '127.0.0.1', 9090)
]));
}
});
$resource = $injector->getInstance(ResourceInterface::class);
echo $resource->get('page://self/?name=Sekai'); // "greeting": "Konichiwa Sekai" from local app
echo $resource->get('page://sekai/?name=World'); // "greeting": "Hello World" from remote(127.0.0.1:9090) app