Skip to content

Instantly share code, notes, and snippets.

@mnapoli
mnapoli / README.md
Last active February 7, 2023 13:29
Bref v1 libs vs v2

Bref v1 libs (php-82-fpm):

591k  5 jan 14:50 libcurl.so.4.8.0
224k  5 jan 14:50 libnghttp2.so.14.24.1
591k  5 jan 14:50 libonig.so.5.3.0
369k  5 jan 14:50 libpq.so.5.15
355k  5 jan 14:50 libsodium.so.23.3.0
1,8M  5 jan 14:50 libxml2.so.2.10.3
142k  5 jan 14:50 libz.so.1.2.13

This code is not compatible with Bref CDK constructs:

const app = new App();

new MyStack(app, `my-stack-dev`);

Why? Bref automatically set the Bref Lambda layer on your functions. But to do that, Bref needs to know the AWS region to pick the right Bref layer ARN. When you don't set the region explicitly, then Bref cannot access the region (the region variable actually returns the ${AWS:Region} CloudFormation variable, which is useless for Bref).

FROM bref/php-80-fpm
# Include any extension you want, for example:
#COPY --from=bref/extra-gd-php-73:0.9.5 /opt /opt
ADD . $LAMBDA_TASK_ROOT
CMD [ "index.php" ]
@mnapoli
mnapoli / README.md
Last active October 22, 2021 17:13
PrettyCI migration

This page will help you run continuous integration for PHP CodeSniffer and PHP-CS-Fixer using GitHub Actions.

To setup GitHub Actions in your repository, create a .github/workflows/ci.yml file in your repository and commit it.

The content of that file depends on the tool you want to run, please read the examples below.

Note: the examples below are provided to get you started easily, it is possible you may need to adjust them to fit your project.

php-cs-fixer

@mnapoli
mnapoli / README.md
Last active January 29, 2020 16:09
Configurable Symfony container for tests

TestKernel.php:

<?php
declare(strict_types = 1);

namespace Test\Fixture;

use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\Loader\LoaderInterface;
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Bref runtime versions</title>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@0.7.4/dist/tailwind.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Poppins:400,600" rel="stylesheet">
<style>
:root {
--font-sans: Open Sans, system-ui, BlinkMacSystemFont, -apple-system, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
@mnapoli
mnapoli / README.md
Created July 17, 2019 11:28
SAM templates vs Serverless templates

SAM template for a Bref HTTP application:

AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31

Resources:
    MyFunction:
        Type: AWS::Serverless::Function
        Properties:

Before (from here):

After:

{
    "sqlStatementResults": [
        {
@mnapoli
mnapoli / Makefile
Last active December 9, 2018 21:57
Bref
deploy: optimize package upload
optimize:
APP_ENV=prod php bin/console cache:clear --no-debug --no-warmup
APP_ENV=prod php bin/console cache:warmup
package:
sam package \
--template-file template.yaml \
--output-template-file .cloudformation.yaml \
--s3-bucket <CREATE A BUCKET MANUALLY AND PUT THE BUCKET NAME HERE>
upload:
exports.handle = function(event, context, callback) {
// exec PHP
};