All Projects → brefphp → Extra Php Extensions

brefphp / Extra Php Extensions

Extra PHP extensions usable in AWS Lambda with the Bref PHP runtimes.

Projects that are alternatives of or similar to Extra Php Extensions

Lambda Refarch Webapp
The Web Application reference architecture is a general-purpose, event-driven, web application back-end that uses AWS Lambda, Amazon API Gateway for its business logic. It also uses Amazon DynamoDB as its database and Amazon Cognito for user management. All static content is hosted using AWS Amplify Console.
Stars: ✭ 1,208 (+1429.11%)
Mutual labels:  aws-lambda, lambda
Chalice
Python Serverless Microframework for AWS
Stars: ✭ 8,513 (+10675.95%)
Mutual labels:  aws-lambda, lambda
Sherlock Holmes Partying In The Jungle
Parses AWS events payloads into a plain JavaScript object
Stars: ✭ 12 (-84.81%)
Mutual labels:  aws-lambda, lambda
Epsagon Go
Automated tracing library for Go 1.x ⚡️
Stars: ✭ 24 (-69.62%)
Mutual labels:  aws-lambda, lambda
Up
Up focuses on deploying "vanilla" HTTP servers so there's nothing new to learn, just develop with your favorite existing frameworks such as Express, Koa, Django, Golang net/http or others.
Stars: ✭ 8,439 (+10582.28%)
Mutual labels:  aws-lambda, lambda
Lambda Deployment Example
Automated Lambda Deployments with Terraform & CodePipeline
Stars: ✭ 25 (-68.35%)
Mutual labels:  aws-lambda, lambda
Lamlight
Lamlight is a command line tool to allow easy handling of AWS lambda functions. It allows to put heavy dependencies like numpy and scipy on AWS lambda and updating your lambda function very quickly.
Stars: ✭ 37 (-53.16%)
Mutual labels:  aws-lambda, lambda
Lambdalogs
A CLI tool to trace AWS Lambda calls over multiple CloudWatch log groups.
Stars: ✭ 18 (-77.22%)
Mutual labels:  aws-lambda, lambda
Apex
Old apex/apex
Stars: ✭ 20 (-74.68%)
Mutual labels:  aws-lambda, lambda
Serverless Es Logs
A Serverless plugin to transport logs to ElasticSearch
Stars: ✭ 51 (-35.44%)
Mutual labels:  aws-lambda, lambda
Serverless Node Simple Image Resize
Simple image resize AWS lambda function
Stars: ✭ 74 (-6.33%)
Mutual labels:  aws-lambda, lambda
Vapor Aws Lambda Runtime
Run your Vapor api server on AWS Lambda using the official Swift Server runtime.
Stars: ✭ 65 (-17.72%)
Mutual labels:  aws-lambda, lambda
Aws Node Elasticache Vpc
Serverless function using elasticache (redis) within VPC
Stars: ✭ 22 (-72.15%)
Mutual labels:  aws-lambda, lambda
Lamb
monitoring tool for better visibility when developing AWS Lambda functions
Stars: ✭ 11 (-86.08%)
Mutual labels:  aws-lambda, lambda
Aws Lambda Workshop
Some incremental examples suitable to host an AWS Lambda Functions workshop
Stars: ✭ 18 (-77.22%)
Mutual labels:  aws-lambda, lambda
Serverless Plugin Stackstorm
Plugin for serverless framework to run ready to use actions from StackStorm Exchange as AWS Lambda.
Stars: ✭ 28 (-64.56%)
Mutual labels:  aws-lambda, lambda
Serverless Plugin Warmup
Keep your lambdas warm during winter. ♨
Stars: ✭ 814 (+930.38%)
Mutual labels:  aws-lambda, lambda
Aws Lambda Resize Images
AWS Lambda function to generate a set of resized images (large, medium, small)
Stars: ✭ 6 (-92.41%)
Mutual labels:  aws-lambda, lambda
Corgi
AWS Lambda / API Gateway native, fast and simple web framework
Stars: ✭ 44 (-44.3%)
Mutual labels:  aws-lambda, lambda
Flogo Contrib
Flogo Contribution repo. Contains activities, triggers, models and actions.
Stars: ✭ 60 (-24.05%)
Mutual labels:  aws-lambda, lambda

Bref Extra PHP Extension

This repository provides PHP extensions for Bref applications via AWS Lambda layers.

This is useful when you want something "off the shelf". If you ever need more than 2-3 layer you should consider creating your own layer. That is because AWS has a limit of 5 layers per Lambda. You can also utilise the provided docker images for local development.

We are happy to get contributions for other extensions. Sky is the limit! (And also your knowledge with Docker...)

Install and configure

composer require bref/extra-php-extensions
# serverless.yml
service: app

provider:
    name: aws
    region: us-east-1
    runtime: provided.al2

plugins:
    - ./vendor/bref/bref
    - ./vendor/bref/extra-php-extensions # <----- Add the extra Serverless plugin

functions:
    console:
        handler: bin/console
        layers:
            - ${bref:layer.php-74}
            - ${bref:extra.amqp-php-74} # <----- Example for AMQP layer
            - ${bref:layer.console}

Available layers

Name Serverless config (php 7.4)
AMQP ${bref:extra.amqp-php-74}
Blackfire ${bref:extra.blackfire-php-74}
Cassandra ${bref:extra.cassandra-php-74}
DS ${bref:extra.ds-php-74}
GD ${bref:extra.gd-php-74}
GMP ${bref:extra.gmp-php-74}
gRPC ${bref:extra.grpc-php-74}
Igbinary ${bref:extra.igbinary-php-74}
Imagick ${bref:extra.imagick-php-74}
IMAP ${bref:extra.imap-php-74}
LDAP ${bref:extra.ldap-php-74}
Mailparse ${bref:extra.mailparse-php-74}
Memcache ${bref:extra.memcache-php-74}
Memcached ${bref:extra.memcached-php-74}
MongoDB ${bref:extra.mongodb-php-74}
MsgPack ${bref:extra.msgpack-php-74}
Newrelic ${bref:extra.newrelic-php-74}
ODBC Snowflake ${bref:extra.odbc-snowflake-php-74}
Pcov ${bref:extra.pcov-php-74}
PostgreSQL ${bref:extra.pgsql-php-74}
Redis ${bref:extra.redis-php-74}
Scrypt ${bref:extra.scrypt-php-74}
Microsoft SQLSRV ${bref:extra.sqlsrv-php-74}
UUID ${bref:extra.uuid-php-74}
Xdebug ${bref:extra.xdebug-php-74}
Yaml ${bref:extra.yaml-php-74}

Blackfire installation

The Blackfire layer only have the probe installed.

You still need to install the agent. The agent is installed on a separate server (not a lambda function). The micro EC2 instance is sufficient to run the Blackfire agent.

Create a blackfire.ini file in php/conf.d/ for your lambda function where you load the extension and modify the agent_socket in order to point it to the Blackfire Agent.

;php/conf.d/blackfire.ini
blackfire.agent_socket = tcp://ip-172-40-40-40.eu-central-1.compute.internal:8307
blackfire.agent_timeout = 0.25

You may tweak other Blackfire parameters. See Blackfire documentation about them.

Then modify your agent config to make sure you are listening to tcp://0.0.0.0:8307.

This blog post could be helpful as it describes how to install the Blackfire Agent.

ODBC Snowflake setup

You need to set the environment variable ODBCSYSINI: /opt/snowflake_odbc/conf/ in your serverless.yaml in order to tell unixODBC to load the ini file of the snowflake client.

You can then use snowflake like this: odbc_connect('DRIVER=SnowflakeDSIIDriver;Server=[name].snowflakecomputing.com;Account=;Schema=;Warehouse=;Database=;Role=', 'username', 'password').

There is more information about the driver ini configuration in the snowflake client documentation but the default configuration is enough in most cases. The easiest way review those is to download the snowflake_odbc directory.

SQL Server setup

The SQL Server layer includes both the SQLSRV extension and the PDO_SQLSRV extension (source). If you are unsure of which extension to use, this stackoverflow post may be helpful. You need to set the environment variable ODBCSYSINI: /opt/microsoft/conf/ in your serverless.yaml in order to tell unixODBC to load the required ini files.

New Relic

Read the New Relic tutorial.

Docker images

There are Docker images for every layer. They are updated on every push to master and on every tag. The name of the image is bref/extra-[name]-php-[version]. Find all images on Docker hub.

These are the same docker images that creates the layers. All layer files lives inside the /opt directory in the image.

Local Development

When developing locally you can build your own images with the required extensions. Example with PHP 7.4 and MongoDB Extension:

docker-compose.yml

  php:
    build:
      context: .
      dockerfile: Dockerfile-phpFpm
    volumes:
      - .:/var/task:ro

Dockerfile-phpFpm

FROM bref/extra-mongodb-php-74 as mongodbextra
FROM bref/php-74-fpm-dev
COPY --from=mongodbextra /opt /opt

For contributors and maintainers

Creating a new layer

The idea is to start from bref/build-php-XX, install all libraries and extensions you want, then move all related files to /opt. Those files will be available in the same same location on the Lambda.

Note that one can't just move files/libraries around. Most of them are expected to be in their "standard" location.

  1. Create a new folder in layers and name it to your extension name.
  2. Add your Dockerfile
  3. Create a config.json file at root of your layer directory specifying php versions it is built for
  4. Create a test.php file with a small test that makes sure the extension is loaded
  5. Update the table in the readme

Please refer here for more details.

Testing the layer

# Test all layers and PHP versions
make test

# Test only a single layer
layer=imagick make test

# Test a single layer on a single PHP version
layer=imagick php_versions=74 make test

Deploy new versions

Use Github actions

Prepare the changelog with some release notes. Then push your changes to prepare-release branch. The Github Action will build an publish layers and then commit the layers.json to your PR.

Now you will just merge and create a tag.

The manual way

export AWS_PROFILE=my_profile
make publish
git add layers.json
git commit -m "New version of layers"
git push

Config

You can also build only one specific layer by providing layer=blackfire to make. Same thing for some specific version(s) of php by providing php_versions="73 74" to make. You can invoke both ways:

# First way: make with named arguments
make layer=gd php_versions=74
# Second way: environment variables passed to make
layer=blackfire php_versions=80 make

Lambda layers in details

Notice: this section is only useful if you want to learn more.

The lambda layers follow this pattern:

arn:aws:lambda:<region>:403367587399:layer:<layer-name>:<layer-version>

See the latest layer versions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].