1. Go to this page and download the library: Download runtime/bref library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
runtime / bref example snippets
// public/index.php
use App\Kernel;
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};
// public/index.php
use Nyholm\Psr7\Response;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
$name = $request->getQueryParams()['name'] ?? 'world';
return new Response(200, [], "Hello $name");
}
};
};
// bin/console
use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application;
$context['APP_DEBUG']);
return new Application($kernel);
};
// bin/container.php
use App\Kernel;
$kernel = new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
$kernel->boot();
return $kernel->getContainer();
};
namespace App\Lambda;
use Bref\Context\Context;
use Bref\Event\Handler;
class HelloWorld implements Handler
{
public function handle($event, Context $context)
{
return 'Hello ' . $event['name'];
}
}
namespace App\Lambda;
use Bref\Context\Context;
use Bref\Event\S3\S3Event;
use Bref\Event\S3\S3Handler;
class S3FileCreated extends S3Handler
{
public function handleS3(S3Event $event, Context $context): void
{
$bucketName = $event->getRecords()[0]->getBucket()->getName();
$fileName = $event->getRecords()[0]->getObject()->getKey();
// do something with the file
}
}