Skip to content

Instantly share code, notes, and snippets.

@paulredmond
paulredmond / .zshrc
Last active Apr 30, 2021
Aliases to clear Laravel logs
View .zshrc
# Must run from the root of a Laravel app
alias clearlog="truncate -s 0 $PWD/storage/logs/laravel.log"
alias clearlogs="truncate -s 0 $PWD/storage/logs/*.log"
# Or using git rev-parse
alias clearlog="truncate -s 0 $(git rev-parse --show-toplevel)/storage/logs/laravel.log"
alias clearlogs="truncate -s 0 $(git rev-parse --show-toplevel)/storage/logs/*.log"
@paulredmond
paulredmond / docker.conf
Last active Apr 13, 2021
Example www pool for PHP-FPM with dynamic Environment variables
View docker.conf
; if you're using the starter bundle file `docker/php/php-fpm.d/docker.conf`
[global]
daemonize = no
pid = run/php-fpm.pid
[www]
listen = /usr/local/var/run/php-fpm.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
@paulredmond
paulredmond / ValidateMailgunWebhook.php
Created Apr 24, 2017
Laravel Middleware to Validate a signed Mailgun webhook
View ValidateMailgunWebhook.php
<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Http\Response;
/**
* Validate Mailgun Webhooks
* @see https://documentation.mailgun.com/user_manual.html#securing-webhooks
@paulredmond
paulredmond / leanpub-tree-view.md
Created Jan 28, 2018
Docker for PHP Developers Leanpub Tree View
View leanpub-tree-view.md
├── .gitignore
├── manuscript
│   ├── Book.txt
│   ├── Sample.txt
│   ├── Subset.txt
│   ├── acknowledgments.md
│   ├── backmatter.txt
│   ├── chapter01.md
│   ├── chapter02.md
@paulredmond
paulredmond / app.js
Last active Sep 26, 2020
Example Vue.js mixins for time
View app.js
import dateMixin from './mixins/date';
// Globally
Vue.mixin(dateMixin);
@paulredmond
paulredmond / Caddyfile
Created Oct 12, 2017
The Caddyfile for a Laravel PHP project - https://caddyserver.com/docs/caddyfile
View Caddyfile
0.0.0.0
root /srv/app/public
gzip
fastcgi / 127.0.0.1:9000 php
rewrite {
regexp .*
ext /
to /index.php?{query}
}
View linux-cheat-sheet.md

System

uname -a     # Display Linux System Information
uname -r     # Display kernel release information
uptime       # Show how long the system has been running + load
hostname     # Show system host name
hostname -i  # Display the IP address of the host
last reboot  # Show system reboot history
date         # Show the current date and time
@paulredmond
paulredmond / HMACRequestHandler.php
Created Apr 7, 2017
Example Guzzle HTTP Middleware for a simple HMAC Authorization
View HMACRequestHandler.php
<?php
namespace App;
use Carbon\Carbon;
use Psr\Http\Message\RequestInterface;
class HMACRequestHandler
{
private $key;
@paulredmond
paulredmond / Dockerfile
Created Nov 26, 2019
Example of a Laravel multi-stage build
View Dockerfile
FROM composer:1.7 as vendor
COPY database/ database/
COPY composer.json composer.json
COPY composer.lock composer.lock
RUN composer install \
--ignore-platform-reqs \
--no-interaction \
@paulredmond
paulredmond / Dockerfile
Created Oct 12, 2017
A Dockerfile for a Laravel PHP Application with Caddy Server
View Dockerfile
FROM php:7.1-fpm
LABEL maintainer="Paul Redmond <paul@bitpress.io>"
# Install application dependencies
RUN curl --silent --show-error --fail --location \
--header "Accept: application/tar+gzip, application/x-gzip, application/octet-stream" -o - \
"https://caddyserver.com/download/linux/amd64?plugins=http.expires,http.realip&license=personal" \
| tar --no-same-owner -C /usr/bin/ -xz caddy \
&& chmod 0755 /usr/bin/caddy \
&& /usr/bin/caddy -version \