Uh oh!
There was an error while loading. Please reload this page.
forked from araines/serverless-php
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.php
More file actions
Latest commit
26 lines (20 loc) · 829 Bytes
/
Copy pathhandler.php
File metadata and controls
26 lines (20 loc) · 829 Bytes
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
<?php
$loader = require__DIR__ . '/vendor/autoload.php';
useRaines\Serverless\Context;
useSymfony\Component\Config\FileLocator;
useSymfony\Component\DependencyInjection\ContainerBuilder;
useSymfony\Component\DependencyInjection\Loader\YamlFileLoader;
// Set up service container
$container = newContainerBuilder();
$loader = newYamlFileLoader($container, newFileLocator(__DIR__ . '/config'));
$loader->load('services.yml');
// Get event data and context object
$event = json_decode($argv[1], true) ?: [];
$logger = $container->get('logger');
$fd = fopen('php://fd/3', 'r+');
$context = newContext($logger, $argv[2], $fd);
// Get the handler service and execute
$handler = $container->get(getenv('HANDLER'));
$response = $handler->handle($event, $context);
// Send data back to shim
printf(json_encode($response));