Download the PHP package runtime/bref without Composer

On this page you can find all versions of the php package runtime/bref. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package bref

Bref Runtime

Deploy an application with AWS Lambda using Bref.

We support all kinds of applications. See the following sections for details.

  1. Installation and usage
  2. Symfony application
  3. Laravel application
  4. PSR-15 application
  5. Console application
  6. PSR-11 container application
    1. Invoke handlers locally
    2. Simplify serverless.yml
    3. Typed handlers
    4. Symfony Messenger integration

If you are new to the Symfony Runtime component, read more in the main readme.

Installation

To get started, we need a serverless.yml file in our projects root. We also use the ./vendor/runtime/bref-layer plugin. Now we can tell AWS that we want to use a "layer" called ${runtime-bref:php-80} to run our application on.

Next we need to define the environment variable APP_RUNTIME so the Runtime component knows what runtime to use.

That is really it!

We use this file for all kinds of applications. The only thing we change in the events. Imagine that we want to listen to changes to S3 or new SQS messages. Or we could let this function to be invoked by another application in our system using a Bref\Event\Handler.

Symfony application

You need some extra features from Bref. Install it with

Use the standard Symfony 5.3+ public/index.php.

There is nothing special you need to do.

Here is an example application. With this runtime you may use the exact same application for in local development and in production.

Laravel application

You need some extra features from Bref. Install it with

To run a Laravel application, you need to update your front controller to look similar to this:

Now you are up and running on AWS Lambda!

See runtime/laravel on how to run this locally.

PSR-15 application

You need some extra features from Bref. Install it with

Bref is using nyholm/psr7 to provide a PSR-7 and PSR-15 experience. See runtime/psr-nyholm how to run your application locally.

The following code is an example PSR-15 application with the Runtime component. If it works locally it will also with on AWS Lambda.

Console application

Use the standard Symfony 5.3+ bin/console.

PSR-11 Container

The PSR-11 container is great. It really shines in internal microservices where you dont have to deal with HTTP or security. Your application just call your microservice using an AWS Lambda api client (ie aws/aws-sdk-php or async-aws/lambda). It is also great for reacting to S3 or SQS events.

The first thing we need is a file that returns a PSR-11 container. See below for an example for Symfony.

Now we write a class/service that implements Bref\Event\Handler.

Now we need to update serverless.yml to say "Use bin/container.php to get the container and then load service App\Lambda\HelloWorld".

When this is deployed it can be invoked by

Invoke handlers locally

Using a service from the container makes the handlers very simple to unit test. However, if you are lazy, you may want to invoke them locally from CLI.

Run the following command to invoke the App\Lambda\HelloWorld service.

If your service expects some event data, add it as a JSON string or a path to a file containing JSON.

Simplify serverless.yml

The syntax handler: bin/container.php:App\Lambda\HelloWorld might be a bit weird to write, but you may add an environment variable called FALLBACK_CONTAINER_FILE which includes the file to where we can get the PSR-11 container. This may help the serverless.yml file to read more natually.

Typed handlers

To better integrate with different AWS events, one can use "typed handlers". These are classes that implements Bref\Event\Handler and provides some helper methods or classes.

To use them, you need to install Bref:

We use the same PSR-11 configuration from above and write custom handler like:

Read more about different typed handlers at Bref's documentation.

Symfony Messenger integration

Similar to the typed handlers above, if you use bref/symfony-messenger you may also want to define a worker function.


All versions of bref with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0.5
ext-json Version *
ext-sockets Version *
clue/arguments Version ^2.1
psr/http-server-handler Version ^1.0
riverline/multipart-parser Version ^2.0.9
runtime/bref-layer Version ^1.3
symfony/runtime Version ^5.4 || ^6.0 || ^7.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package runtime/bref contains the following files

Loading the files please wait ....