Download the PHP package cachewerk/bref-laravel-bridge without Composer
On this page you can find all versions of the php package cachewerk/bref-laravel-bridge. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cachewerk/bref-laravel-bridge
More information about cachewerk/bref-laravel-bridge
Files in cachewerk/bref-laravel-bridge
Package bref-laravel-bridge
Short Description An advanced Laravel integration for Bref, including Octane support.
License MIT
Homepage https://github.com/cachewerk/bref-laravel-bridge
Informations about the package 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, Laravel Vapor and Bref's Laravel Bridge.
Background
Why does this exist and why not just use Laravel Vapor? 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'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 + Serverless Framework 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
First, be sure to familiarize yourself with Bref and its guide to Serverless Laravel applications.
Next, install the package and publish the custom 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
:
Then set up your functions:
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:
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:
Check out some more comprehensive examples.
Configuration
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:
Then define the files you want to serve in bref.assets
.
Lastly tell Bref to support binary responses on your web
function:
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
either in your RDS database's parameter group, or on a specific database itself.
Lastly, set the OCTANE_PERSIST_DATABASE_SESSIONS
environment variable.
Usage
Artisan Console
Just like with Bref, you may execute console commands.
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:
You can then quickly put all functions into maintenance without running a full build and CloudFormation deploy:
To take your app out of maintenance mode, simply omit the parameter:
One caveat with the --update-config
flag is that it doesn't do objects in environment
variables in the serverless.yml
:
All versions of bref-laravel-bridge with dependencies
aws/aws-sdk-php Version ^3.222
bref/bref Version ^1.5
illuminate/container Version ^8.0|^9.0
illuminate/contracts Version ^8.0|^9.0
illuminate/http Version ^8.0|^9.0
illuminate/queue Version ^8.0|^9.0
illuminate/support Version ^8.0|^9.0
laravel/octane Version ^1.2
monolog/monolog Version ^2.0
riverline/multipart-parser Version ^2.0