Skip to content

1.0.1

Compare
Choose a tag to compare
@mnapoli mnapoli released this 29 Nov 18:28
· 1778 commits to master since this release
2640d11

A new Bref release already? Hell yeah! PHP 8 is there πŸš€

This release comes with new runtime versions:

  • if you use serverless.yml, you don't have anything to do 😎 (if you upgrade from Bref 0.5, read the 1.0 upgrade guide though)
  • if you use SAM or CloudFormation or Terraform or CDK, update the layer version numbers (see runtimes.bref.sh)

Full diff

Enhancements:

  • Upgrade all PHP versions, including PHP 8.0.0 πŸŽ‰ #802 (@shouze πŸ…)
  • Report nested exception in logs #800 (@tyx)
  • Expose API Gateway path parameters #805 (@mnapoli):

This makes API Gateway a bit more usable as an application router.

Here is an example:

functions:
    get-article:
        handler: get-article-handler.php
        layers:
            - ${bref:layer.php-74}
        events:
            - httpApi: 'GET /articles/{id}'

Path parameters (e.g. {id} in the example above) are now available as request attributes in the PSR-7 request:

<?php

require __DIR__ . '/vendor/autoload.php';

use Nyholm\Psr7\Response;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;

class HttpHandler implements RequestHandlerInterface
{
    public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $id = $request->getAttribute('id');

        return new Response(200, [], "Hello $id");
    }
}

return new HttpHandler();

Looking to support the project? Check out: