Skip to content

Instantly share code, notes, and snippets.


Ralph Schindler ralphschindler

View GitHub Profile
ralphschindler / .php_cs.dist
Created Apr 20, 2021
Generic PHP-CS-Fixer Rules
View .php_cs.dist
$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
return (new PhpCsFixer\Config)
ralphschindler / Dockerfile
Last active Dec 15, 2020
Dockerfile for setting up PHP 8 and xdebug to demonstrate an issue
View Dockerfile
FROM ubuntu:20.10
RUN mkdir /app
RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
apt-get install -qqy --no-install-recommends \
ca-certificates \
valgrind \
ralphschindler / SnapshotCommand.php
Created Jul 11, 2019
An example Laravel app command to create and load database snapshots using S3
View SnapshotCommand.php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
class SnapshotCommand extends Command
ralphschindler / AuthServiceProvider.php
Last active Apr 5, 2019
Laravel 5.8 Policy Guesser For Using "Models" Directory
View AuthServiceProvider.php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
class AuthServiceProvider extends ServiceProvider
ralphschindler / StringIsLengthRule.php
Last active Apr 19, 2021
Custom Dynamic Validation Rules for Laravel 5.5+
View StringIsLengthRule.php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class StringIsLengthRule implements Rule
protected $length;
protected $message = 'The string must be greater than the length';
ralphschindler /
Last active Nov 2, 2017
Ralph's Database Column Organization

Ralph's Database Column Organization


  1. primary key columns (e.g. id)
  2. foreign key columns (e.g. other_id)
  3. row qualifying columns (e.g. status)
  4. entity identification columns (e.g. name, title, slug, base_url)
  5. non-string-based entity attribute columns (e.g. rating, is_admin)
  6. string-based entity attribute columns (e.g. short_description, description, notes)
ralphschindler /
Last active Apr 16, 2021
Docker For Mac Host Address Alias To Enable PHP XDebug ( Trick)

Docker (Mac) De-facto Standard Host Address Alias

This launchd script will ensure that your Docker environment on your Mac will have as an alias on your loopback device ( The command being run is ifconfig lo0 alias

Once your machine has a well known IP address, your PHP container will then be able to connect to it, specifically XDebug can connect to it at the configured xdebug.remote_host.

Installation Of IP Alias (This survives reboot)

Copy/Paste the following in terminal with sudo (must be root as the target directory is owned by root)...

ralphschindler / scalar-type-signatures.php
Created Feb 10, 2015
What happened when this was suggested many years ago?
View scalar-type-signatures.php
// coercive types, as per PersonFactory author's specification
class ElePHPant {
public $name, $age, $cuteness, $evil;
public function __construct(~string $name, ~int $age, ~float $cuteness, ~bool $evil) {
$this->name = $name;
$this->age = $age;
$this->cuteness = $cuteness;
$this->evil = $evil;
ralphschindler / colorize.php
Created Dec 26, 2014
CLI Colorization via HTML style tagging function. This solution is UNLICENSED, feel free to do whatever you want with it.
View colorize.php
/** @license */
function colorize($string, $useAnsi = null)
if (is_null($useAnsi)) {
$useAnsi = function_exists('posix_isatty');
ralphschindler / SampleOAuth2Client.php
Created Nov 26, 2014
A Barebones OAuth2 PHP Client demonstrating the "Password Grant Type"
View SampleOAuth2Client.php
namespace SampleOauth2Client;
class Client
protected $configuration = [
'token_file' => null, // path to a file to store token information
'api_authorization_token' => null, // authorization to talk to token service
'api_token_url' => null, // url to post to