Download the PHP package xp-forge/lambda without Composer

On this page you can find all versions of the php package xp-forge/lambda. 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 lambda

AWS Lambda for the XP Framework

Build status on GitHub XP Framework Module BSD Licence Requires PHP 7.0+ Supports PHP 8.0+ Latest Stable Version

Serverless infrastructure.

Example

Put this code in a file called Greet.class.php:

The two parameters passed are $event (a value depending on where the lambda was invoked from) and $context (a Context instance, see below).

Initialization

If you need to run any initialization code, you can do so before returning the lambda from target(). This code is only run once during the init phase:

The lambda's environment accessible via $this->environment is an Environment instance, see below.

Logging

To write output to the lambda's log stream, use trace():

Any non-string arguments passed will be converted to string using util.Objects::stringOf(). To integrate with XP logging, pass the environment's writer to the console appender, e.g. by using $cat= Logging::all()->toConsole($this->environment->writer).

Response streaming

This library supports AWS Lambda response streaming as announced by AWS in April 2023. To use the stream, return a function(var, Stream, Context) from the handler's target() method instead of a function(var, Context):

Invoking this lambda will yield the following:

Streaming in Terminal

The Stream interface is defined as follows:

Development

To run your lambda locally, use the following:

This does not provide a complete lambda environment, and does not have any execution limits imposed on it! To detect this programmatically, use $this->environment->local(), which will return true.

Integration testing

To test your lambda inside a local containerized lambda environment, use the test command.

This functionality is provided by the AWS Lambda base images for custom runtimes. Although this also runs on your machine, $this->environment->local() will return false.

Setup

The first step is to create and publish the runtime layer:

...and create a role:

After ensuring your dependencies are up-to-date using composer, create the function:

Invocation

To invoke the function:

Deploying changes

After having initially created your lambda, you can update its code as follows:

Upgrading the runtime

To upgrade an existing runtime layer, build the new runtime and publish a new version by calling the following to create a new version:

Now, switch the function over to use this new layer:

Using other AWS services

In order to programmatically use other AWS services use the ServiceEndpoint class:

To test this locally, pass the necessary environment variables via -e on the command line:

Context

The context object passed to the target lambda is defined as follows:

Environment

The runtime environment is defined as follows:

Interfaces

Instead of functions, a handler's target() method may also return instances implementing the Lambda or Streaming interfaces:

See also


All versions of lambda with dependencies

PHP Build Version
Package Version
Requires xp-framework/core Version ^12.0 | ^11.0 | ^10.14
xp-framework/http Version ^10.0 | ^9.0
xp-framework/zip Version ^11.0 | ^10.0 | ^9.0
xp-forge/aws Version ^1.0
xp-forge/json Version ^5.0 | ^4.0
php Version >=7.0.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 xp-forge/lambda contains the following files

Loading the files please wait ....