Skip to content

Commit 547d211

Browse files
authored
Merge pull request #1953 from brefphp/v3
Bref v3
2 parents 44ab574 + 3f856bf commit 547d211

File tree

81 files changed

+1525
-1402
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1525
-1402
lines changed

.github/aws/github-role.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ Resources:
1515
- Effect: Allow
1616
Action: sts:AssumeRoleWithWebIdentity
1717
Principal:
18-
Federated: arn:aws:iam::534081306603:oidc-provider/token.actions.githubusercontent.com
18+
Federated: arn:aws:iam::873528684822:oidc-provider/token.actions.githubusercontent.com
1919
Condition:
2020
StringLike:
2121
token.actions.githubusercontent.com:sub: !Sub repo:${FullRepoName}:*
2222
Policies:
23-
- PolicyName: RetrieveLayersForLayerJsRole
23+
- PolicyName: RetrieveLayersForLayerRole
2424
PolicyDocument:
2525
Statement:
2626
- Effect: Allow

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: CI
22

33
on:
44
push:
5-
branches: ['master', '2.x']
5+
branches: ['master', '2.x', 'v3']
66
pull_request:
77
branches: ['*']
88
schedule:
@@ -16,11 +16,11 @@ jobs:
1616
timeout-minutes: 15
1717
strategy:
1818
matrix:
19-
php: [ '8.4', '8.3', '8.2', '8.1', '8.0' ]
19+
php: [ '8.5', '8.4', '8.3', '8.2' ]
2020
dependency-version: [ '' ]
2121
platform-reqs: [ '' ]
2222
include:
23-
- php: '8.0'
23+
- php: '8.2'
2424
dependency-version: '--prefer-lowest'
2525
steps:
2626
- name: Checkout
@@ -40,7 +40,7 @@ jobs:
4040
coverage: none
4141
ini-values: expose_php=1
4242
- name: Install dependencies
43-
run: 'composer update ${{ matrix.dependency-version }} --no-interaction --prefer-dist --no-progress --no-security-blocking ${{ matrix.platform-reqs }}'
43+
run: 'composer update ${{ matrix.dependency-version }} --no-interaction --prefer-dist --no-progress ${{ matrix.platform-reqs }}'
4444
- name: Execute Unit Tests
4545
run: 'vendor/bin/phpunit --testsuite small'
4646

.github/workflows/update-layer-versions.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Update layer versions (Bref v2)
1+
name: Update layer versions
22

33
# Triggered manually or automatically when new Bref layers published
44
on:
@@ -29,12 +29,12 @@ jobs:
2929
steps:
3030
- uses: actions/checkout@v6
3131
with:
32-
ref: master
32+
ref: v3 # temporary until v3 becomes the main branch
3333

3434
- name: Set AWS credentials
3535
uses: aws-actions/configure-aws-credentials@v4
3636
with:
37-
role-to-assume: arn:aws:iam::534081306603:role/bref-github-actions
37+
role-to-assume: arn:aws:iam::873528684822:role/bref-github-actions
3838
role-session-name: bref-github-actions
3939
aws-region: us-east-1
4040

@@ -50,10 +50,10 @@ jobs:
5050
- run: make layers.json
5151

5252
- name: Create Pull Request
53-
uses: peter-evans/create-pull-request@v5
53+
uses: peter-evans/create-pull-request@v7
5454
with:
5555
commit-message: Update layer versions
56-
title: Update Lambda layers [${{ inputs.release_name }}](${{ inputs.release_html_url }})
56+
title: Update v3 layers [${{ inputs.release_name }}](${{ inputs.release_html_url }})
5757
body: |
5858
New AWS Lambda layers [have been released](https://github.com/brefphp/aws-lambda-layers/releases):
5959
@@ -63,7 +63,8 @@ jobs:
6363
After merging, a new Bref release needs to be created.
6464
6565
If you are using AWS Lambda layer ARNs, check out [runtimes.bref.sh](https://runtimes.bref.sh/) to see the latest ARNs.
66-
branch: new-layer-versions
66+
branch: new-layer-versions-v3
67+
base: v3 # temporary until v3 becomes the main branch
6768
delete-branch: true # delete after merging or closing the PR
6869
# https://github.com/actions/checkout/issues/13#issuecomment-724415212
6970
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
/website/node_modules/
77
.DS_Store
88
/.serverless/
9-
.phpunit.result.cache
9+
.phpunit.cache
1010
node_modules/
1111
package-lock.json
12-
/.phpunit.cache/test-results
1312
/.claude

.phpcs.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
<!-- Show sniff names -->
88
<arg value="s"/>
99

10-
<file>bref</file>
1110
<file>src</file>
1211
<file>tests</file>
1312

bref

Lines changed: 0 additions & 132 deletions
This file was deleted.

composer.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,10 @@
1616
}
1717
},
1818
"bin": [
19-
"bref",
2019
"src/bref-local"
2120
],
2221
"require": {
23-
"php": ">=8.0",
22+
"php": ">=8.2",
2423
"ext-curl": "*",
2524
"ext-json": "*",
2625
"crwlr/query-string": "^1.0.3",
@@ -30,20 +29,20 @@
3029
"psr/http-message": "^1.0|^2.0",
3130
"psr/http-server-handler": "^1.0",
3231
"riverline/multipart-parser": "^2.1.2",
33-
"symfony/process": "^4.4|^5.0|^6.0|^7.0|^8.0"
32+
"symfony/process": "^6.4|^7.0|^8.0"
3433
},
3534
"require-dev": {
3635
"async-aws/core": "^1.0",
37-
"async-aws/lambda": "^1.0",
36+
"async-aws/lambda": "^2.0",
3837
"aws/aws-sdk-php": "^3.172",
3938
"bref/secrets-loader": "^1.0",
40-
"dms/phpunit-arraysubset-asserts": "^0.4",
39+
"dms/phpunit-arraysubset-asserts": "^0.5",
4140
"doctrine/coding-standard": "^8.0",
4241
"guzzlehttp/guzzle": "^7.5",
43-
"phpstan/phpstan": "^1.10.26",
44-
"phpunit/phpunit": "^9.6.10",
45-
"symfony/console": "^4.4|^5.0|^6.0|^7.0|^8.0",
46-
"symfony/yaml": "^4.4|^5.0|^6.0|^7.0|^8.0"
42+
"phpstan/phpstan": "^2",
43+
"phpunit/phpunit": "^10.1",
44+
"symfony/console": "^6.4|^7.0|^8.0",
45+
"symfony/yaml": "^6.4|^7.0|^8.0"
4746
},
4847
"scripts": {
4948
"test": [

demo/http.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

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

5+
if (isset($_GET['crash'])) {
6+
throw new \Exception('Crash!');
7+
}
8+
59
if (isset($_GET['sleep'])) {
610
error_log('This is a log');
711
sleep(10);

docs/default/cli-commands.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ We can run CLI commands and scripts on AWS Lambda by deploying a "console" funct
88
functions:
99
cli:
1010
handler: the-php-script-to-run.php
11-
runtime: php-81-console
11+
runtime: php-84-console
1212
```
1313
1414
The function uses the [Console runtime](../runtimes/console.mdx).

docs/default/getting-started.mdx

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,29 @@ Next, in an empty directory, install Bref using Composer:
2727
composer require bref/bref
2828
```
2929

30-
Make sure that the version of Bref that was installed is 1.0 or greater.
30+
Make sure that the version of Bref that was installed is 3.0 or greater.
3131

32-
Then let's start by initializing a new project by running:
32+
Then, create a `serverless.yml` file. This file will describe how to deploy your application.
3333

34-
```bash
35-
vendor/bin/bref init
36-
```
37-
38-
Accept all the defaults by pressing "Enter". The following files will be created in your project:
39-
40-
- `index.php` contains the code of your application
41-
- `serverless.yml` contains the configuration for deploying on AWS
42-
43-
You are free to edit `index.php`.
34+
```yml filename="serverless.yml"
35+
service: app # your application name (lowercase without spaces)
4436

45-
To deploy an existing application, you can delete `index.php` and edit `serverless.yml` to point to your existing index file (for example it may be another file like `public/index.php`). You can also create the `serverless.yml` file manually:
37+
bref:
38+
# Uncomment and set your team ID if you are using Bref Cloud
39+
#team: bref-team-id
4640

47-
```yml filename="serverless.yml"
48-
service: app
4941
provider:
5042
name: aws
51-
region: us-east-1
43+
region: us-east-1 # AWS region to deploy to
44+
environment: # Environment variables
45+
APP_ENV: prod
5246

5347
functions:
5448
web:
49+
# `index.php` is the entrypoint of your application
5550
handler: index.php
56-
runtime: php-81-fpm
51+
runtime: php-84-fpm
52+
timeout: 28 # in seconds (API Gateway has a max timeout of 29 seconds)
5753
events:
5854
- httpApi: '*'
5955

@@ -66,6 +62,21 @@ plugins:
6662
- ./vendor/bref/bref
6763
```
6864
65+
If your `index.php` entrypoint is in a different folder, feel free to adjust the `handler` key. For example if it is in `public/index.php`:
66+
67+
```yml
68+
handler: public/index.php
69+
```
70+
71+
If this is a new application, you can create a very simple `index.php` file to test things out, for example:
72+
73+
```php
74+
<?php
75+
echo 'Hello world!';
76+
```
77+
78+
You will also want to add `.serverless` to your `.gitignore`.
79+
6980
## Deployment
7081

7182
To deploy, run:

0 commit comments

Comments
 (0)