|
| 1 | +# Bref layers for PHP Runtime |
| 2 | + |
| 3 | +This repository provides Bref layers to run Symfony Runtime applications on |
| 4 | +AWS Lambda. It is automatically updated to sync with the changes in [Bref](https://github.com/brefphp/bref). |
| 5 | +These layers are just replacing Bref's "function layer" with a new boostrap file. |
| 6 | +See the [Dockerfile](https://github.com/php-runtime/bref-layer/blob/main/layers/bref/Dockerfile). |
| 7 | + |
| 8 | +You will find more information how to run your applicaiton with the runtime component |
| 9 | +at https://github.com/php-runtime/bref |
| 10 | + |
| 11 | +## Install and configure |
| 12 | + |
| 13 | +```cli |
| 14 | +composer require runtime/bref-layer |
| 15 | +``` |
| 16 | + |
| 17 | +```yaml |
| 18 | +# serverless.yml |
| 19 | +service: appgit init |
| 20 | + |
| 21 | +provider: |
| 22 | + name: aws |
| 23 | + region: us-east-1 |
| 24 | + runtime: provided.al2 |
| 25 | + |
| 26 | +plugins: |
| 27 | + - ./vendor/runtime/bref-layer # <----- Add the extra Serverless plugin |
| 28 | + |
| 29 | +functions: |
| 30 | + website: |
| 31 | + handler: public/index.php |
| 32 | + layers: |
| 33 | + - ${runtime-bref:php-80} |
| 34 | + events: |
| 35 | + - httpApi: '*' |
| 36 | +``` |
| 37 | +
|
| 38 | +You will use the same layer for console applications, PSR-11, PSR-15, Laravel or |
| 39 | +Symfony applications. Anything the Runtime component supports. |
| 40 | +
|
| 41 | +## FAQ |
| 42 | +
|
| 43 | +#### Can I use custom php extensions? |
| 44 | +
|
| 45 | +Yes, you can. See the [`bref/extra-php-extensions`](https://github.com/brefphp/extra-php-extensions) |
| 46 | +package. |
| 47 | + |
| 48 | +#### Do I need to install bref/bref? |
| 49 | + |
| 50 | +The [`bref/bref`](https://github.com/brefphp/bref) package includes both layers |
| 51 | +and a lot of features to make it easier to write applications on AWS Lambda. |
| 52 | +You do not **have to** include `bref/bref` if you only want the layers. But most |
| 53 | +HTTP applications probably will. |
| 54 | + |
| 55 | +#### Why not include this package in bref/bref? |
| 56 | + |
| 57 | +There is [an open PR](https://github.com/brefphp/bref/pull/889) to do just that. |
| 58 | +There is also [an open PR](https://github.com/brefphp/bref/pull/1034) to make the |
| 59 | +function layer support the runtime component natively. |
| 60 | + |
| 61 | +Until any of these PRs are merged, we have this layer to help making a good experience |
| 62 | +as possible for the runtime users. |
| 63 | + |
| 64 | +#### Why not use the layer from bref/extra-php-extensions? |
| 65 | + |
| 66 | +The [bref/extra-php-extensions](https://github.com/brefphp/extra-php-extensions) |
| 67 | +has a layer called `${bref-extra:symfony-runtime-php-74}`. It adds the custom bootstrap |
| 68 | +file needed for the Runtime component. |
| 69 | + |
| 70 | +AWS has a hard limit on max 5 layers per function. So instead of using two layers |
| 71 | +(`${bref:layer.php-80}` + `${bref-extra:symfony-runtime-php-74}`) one can use only |
| 72 | +`${runtime-bref:php-80}`. |
| 73 | + |
| 74 | +#### What is your relation to Bref? |
| 75 | + |
| 76 | +We **LOVE** Bref. They are the best ever. Consider sponsoring [Matthieu Napoli |
| 77 | +](https://github.com/mnapoli) for his work. |
| 78 | + |
| 79 | +## Maintainer notes |
| 80 | + |
| 81 | +### Testing the layer |
| 82 | + |
| 83 | +``` |
| 84 | +# Test all layers and PHP versions |
| 85 | +make test |
| 86 | + |
| 87 | +# Test only a single layer |
| 88 | +layer=bref make test |
| 89 | + |
| 90 | +# Test a single layer on a single PHP version |
| 91 | +layer=bref php_versions=74 make test |
| 92 | +``` |
| 93 | +
|
| 94 | +### Deploy new versions |
| 95 | +
|
| 96 | +#### The manual way |
| 97 | +
|
| 98 | +``` |
| 99 | +export AWS_PROFILE=my_profile |
| 100 | +make publish |
| 101 | +git add layers.json |
| 102 | +git commit -m "New version of layers" |
| 103 | +git push |
| 104 | +``` |
| 105 | +
|
| 106 | +## Lambda layers in details |
| 107 | +
|
| 108 | +> **Notice:** this section is only useful if you want to learn more. |
| 109 | +
|
| 110 | +The lambda layers follow this pattern: |
| 111 | +
|
| 112 | +``` |
| 113 | +arn:aws:lambda:<region>:403367587399:layer:bref-<layer-name>:<layer-version> |
| 114 | +``` |
| 115 | +
|
| 116 | +See the [latest layer versions](https://raw.githubusercontent.com/php-runtime/bref-layer/main/layers.json). |
0 commit comments