Skip to content

Instantly share code, notes, and snippets.

@mnapoli
mnapoli / .zshrc
Last active August 24, 2018 16:52
Docker Compose shortcut
# Docker-Compose shortcut:
# - before: docker-compose exec app <command>
# - after: d <command>
# The alias will auto-start the service if it is stopped.
# Requirements:
# - jq: https://stedolan.github.io/jq/
# - yq: https://github.com/kislyuk/yq
# Add this to your `~/.zshrc` at the end because `d` is an existing (unrelated) alias we want to override
@mnapoli
mnapoli / README.md
Last active August 31, 2018 12:04
Docker + xdebug

php.ini:

xdebug.remote_enable=on
xdebug.remote_autostart=on
xdebug.remote_port=9000
xdebug.remote_host=host.docker.internal
xdebug.remote_connect_back=0
<?php
// See https://wiki.php.net/rfc/named_params
return new TwigConfig(
paths => [
'%kernel.project_dir%/vendor/acme/foo-bar/templates' => 'foo_bar',
],
autoescape => true,
strictVariables => false,
@mnapoli
mnapoli / example.php
Created October 26, 2018 18:12
Async MySQL
<?php
use ProxyManager\Factory\LazyLoadingValueHolderFactory;
use ProxyManager\Proxy\ProxyInterface;
require_once __DIR__ . '/vendor/autoload.php';
$mysql = mysqli_connect('localhost', 'root', '', 'example');
$factory = new LazyLoadingValueHolderFactory();
exports.handle = function(event, context, callback) {
// exec PHP
};
@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:

Before (from here):

After:

{
    "sqlStatementResults": [
        {
@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:
<!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
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;