PHPackages                             cachewerk/bref-laravel-bridge - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Caching](/categories/caching)
4. /
5. cachewerk/bref-laravel-bridge

AbandonedArchivedLibrary[Caching](/categories/caching)

cachewerk/bref-laravel-bridge
=============================

An advanced Laravel integration for Bref, including Octane support.

v0.3.0(3y ago)397.4k8[1 issues](https://github.com/cachewerk/bref-laravel-bridge/issues)MITPHPPHP ^8.0

Since May 18Pushed 3y ago1 watchersCompare

[ Source](https://github.com/cachewerk/bref-laravel-bridge)[ Packagist](https://packagist.org/packages/cachewerk/bref-laravel-bridge)[ Docs](https://github.com/cachewerk/bref-laravel-bridge)[ RSS](/packages/cachewerk-bref-laravel-bridge/feed)WikiDiscussions main Synced today

READMEChangelog (3)Dependencies (10)Versions (6)Used By (0)

Bref Laravel Bridge
===================

[](#bref-laravel-bridge)

An advanced Laravel integration for Bref, including Octane support.

This project is largely based on code from [PHP Runtimes](https://github.com/php-runtime/runtime), [Laravel Vapor](https://github.com/laravel/vapor-core) and [Bref's Laravel Bridge](https://github.com/brefphp/laravel-bridge).

Background
----------

[](#background)

Why does this exist and why not just use [Laravel Vapor](https://vapor.laravel.com)? Vapor is fantastic, easy to use and the better choice for situations, its $399/year pay for itself not having to maintain your own infrastructure.

For [Relay](https://relay.so)'s API however we needed something that 1) **is open source** *(Vapor's API is a black box)*, 2) **is secure** *(Vapor has admin access to databases and environment variables)* and 3) doesn't leave us at the **mercy of a support team** *(Vapor has no enterprise support)*. We also didn't want to be forced to use CloudFront on top of Cloudflare, but that's just nerdy preference.

We needed an open source solution that gives us more fine-grained control and is secure.

[Bref](https://bref.sh) + [Serverless Framework](https://www.serverless.com/) is exactly that, however Bref's Laravel integration is rather basic, it easily exposes SSM secrets and it doesn't support Laravel Octane.

So we built this.

Installation
------------

[](#installation)

First, be sure to familiarize yourself with Bref and its guide to [Serverless Laravel applications](https://bref.sh/docs/frameworks/laravel.html).

Next, install the package and publish the custom Bref runtime:

```
composer require cachewerk/bref-laravel-bridge

php artisan vendor:publish --tag=bref-runtime

```

By default the runtime is published to `php/` where Bref's PHP configuration resides, but it can be move anywhere.

Next, we need to set up in the `AWS_ACCOUNT_ID` environment variable in your `serverless.yml`:

```
provider:
  environment:
    AWS_ACCOUNT_ID: ${aws:accountId}
```

Then set up your functions:

```
functions:
  web:
    handler: php/runtime.php
    environment:
      APP_RUNTIME: octane
      BREF_LOOP_MAX: 250
    layers:
      - ${bref:layer.php-81}
    events:
      - httpApi: '*'

  queue:
    handler: php/runtime.php
    timeout: 59
    environment:
      APP_RUNTIME: queue
    layers:
      - ${bref:layer.php-81}
    events:
      - sqs:
          arn: !GetAtt Queue.Arn
          batchSize: 1
          maximumBatchingWindow: 60

  cli:
    handler: php/runtime.php
    timeout: 720
    environment:
      APP_RUNTIME: cli
    layers:
      - ${bref:layer.php-81}
      - ${bref:layer.console}
    events:
      - schedule:
          rate: rate(1 minute)
          input: '"schedule:run"'
```

If you don't want to use Octane, simply remove `APP_RUNTIME` and `BREF_LOOP_MAX` from the `web` function.

To avoid setting secrets as environment variables on your Lambda functions, you can inject them directly into the Lambda runtime:

```
provider:
  environment:
    APP_SSM_PREFIX: /${self:service}-${sls:stage}/
    APP_SSM_PARAMETERS: "APP_KEY, DATABASE_URL"
```

This will inject `APP_KEY` and `DATABASE_URL` using your service name and stage, for example from `/myapp-staging/APP_KEY`.

Finally, deploy your app:

```
sls deploy --stage=staging

```

Check out some more [comprehensive examples](examples/).

Configuration
-------------

[](#configuration)

### Serving static assets

[](#serving-static-assets)

If you want to serve some static assets from your app's `public` directory, you can use the `ServeStaticAssets` middleware.

First, publish the configuration:

```
php artisan vendor:publish --tag=bref-config

```

Then define the files you want to serve in `bref.assets`.

Lastly tell Bref to support binary responses on your `web` function:

```
functions:
  web:
    handler: php/runtime.php
    environment:
      BREF_BINARY_RESPONSES: 1
```

### Persistent database sessions

[](#persistent-database-sessions)

If you're using PostgreSQL 9.6 or newer, you can take advantage of persistent database sessions.

First set [`idle_in_transaction_session_timeout`](https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-IDLE-IN-TRANSACTION-SESSION-TIMEOUT) either in your RDS database's parameter group, or on a specific database itself.

```
ALTER DATABASE SET idle_in_transaction_session_timeout = '10000' -- 10 seconds in ms
```

Lastly, set the `OCTANE_PERSIST_DATABASE_SESSIONS` environment variable.

```
functions:
  web:
    handler: php/runtime.php
    environment:
      APP_RUNTIME: octane
      BREF_LOOP_MAX: 250
      OCTANE_PERSIST_DATABASE_SESSIONS: 1
```

Usage
-----

[](#usage)

### Artisan Console

[](#artisan-console)

Just like with Bref, you may [execute console commands](https://bref.sh/docs/runtimes/console.html).

```
vendor/bin/bref cli --cli -- route:list

vendor/bin/bref cli example-staging-cli -- route:list

```

### Maintenance mode

[](#maintenance-mode)

Similar to the `php artisan down` command, you may put your app into maintenance mode. All that's required is setting the `MAINTENANCE_MODE` environment variable:

```
provider:
  environment:
    MAINTENANCE_MODE: ${param:maintenance, null}
```

You can then quickly put all functions into maintenance without running a full build and CloudFormation deploy:

```
serverless deploy function --function=web --update-config --param="maintenance=1"
serverless deploy function --function=cli --update-config --param="maintenance=1"
serverless deploy function --function=queue --update-config --param="maintenance=1"

```

To take your app out of maintenance mode, simply omit the parameter:

```
serverless deploy function --function=web --update-config
serverless deploy function --function=cli --update-config
serverless deploy function --function=queue --update-config

```

One caveat with the `--update-config` flag is that it doesn't do objects in `environment` variables in the `serverless.yml`:

```
provider:
  environment:
    SQS_QUEUE: ${self:service}-${sls:stage}    # good
    SQS_QUEUE: !Ref QueueName                  # bad
    SQS_QUEUE:                                 # bad
      Ref: QueueName
```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 71.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~96 days

Total

4

Last Release

1215d ago

Major Versions

v0.3.0 → v2.x-dev2023-03-05

### Community

Maintainers

![](https://www.gravatar.com/avatar/a730bb071d0b4892339f75b4707b6b651733e5f49297af31746dd9e99d4a0e1c?d=identicon)[tillkruss](/maintainers/tillkruss)

---

Top Contributors

[![tillkruss](https://avatars.githubusercontent.com/u/665029?v=4)](https://github.com/tillkruss "tillkruss (43 commits)")[![szepeviktor](https://avatars.githubusercontent.com/u/952007?v=4)](https://github.com/szepeviktor "szepeviktor (9 commits)")[![georgeboot](https://avatars.githubusercontent.com/u/884482?v=4)](https://github.com/georgeboot "georgeboot (8 commits)")

---

Tags

breflaravellaravel-octaneserverless-frameworklaravelbref

### Embed Badge

![Health badge](/badges/cachewerk-bref-laravel-bridge/health.svg)

```
[![Health](https://phpackages.com/badges/cachewerk-bref-laravel-bridge/health.svg)](https://phpackages.com/packages/cachewerk-bref-laravel-bridge)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[bref/laravel-bridge

An advanced Laravel integration for Bref, including Octane support.

3404.5M15](/packages/bref-laravel-bridge)[pressbooks/pressbooks

Pressbooks is an open source book publishing tool built on a WordPress multisite platform. Pressbooks outputs books in multiple formats, including PDF, EPUB, web, and a variety of XML flavours, using a theming/templating system, driven by CSS.

45444.2k1](/packages/pressbooks-pressbooks)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M188](/packages/laravel-ai)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77022.3M145](/packages/laravel-mcp)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M129](/packages/roots-acorn)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
