Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthieu Napoli mnapoli

View GitHub Profile
View README.md

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).

View Dockerfile
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 Oct 22, 2021
PrettyCI migration
View README.md

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 Jan 29, 2020
Configurable Symfony container for tests
View README.md

TestKernel.php:

<?php
declare(strict_types = 1);

namespace Test\Fixture;

use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\Loader\LoaderInterface;
View index.html
<!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 Jul 17, 2019
SAM templates vs Serverless templates
View README.md

SAM template for a Bref HTTP application:

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

Resources:
    MyFunction:
        Type: AWS::Serverless::Function
        Properties:
View README.md

Before (from here):

After:

{
    "sqlStatementResults": [
        {
View Makefile
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:
View handler.js
exports.handle = function(event, context, callback) {
// exec PHP
};
View example.php
<?php
use ProxyManager\Factory\LazyLoadingValueHolderFactory;
use ProxyManager\Proxy\ProxyInterface;
require_once __DIR__ . '/vendor/autoload.php';
$mysql = mysqli_connect('localhost', 'root', '', 'example');
$factory = new LazyLoadingValueHolderFactory();