Skip to content

Instantly share code, notes, and snippets.

View ralphschindler's full-sized avatar

Ralph Schindler ralphschindler

View GitHub Profile
@ralphschindler
ralphschindler / example.php
Created October 24, 2012 23:18
Zend\Db\Sql\Select example usage
View example.php
<?php
use Zend\Db\Sql\Select;
// basic table
$select0 = new Select;
$select0->from('foo');
// 'SELECT "foo".* FROM "foo"';
@ralphschindler
ralphschindler / README.md
Last active September 30, 2023 19:28
Docker For Mac Host Address Alias To Enable PHP XDebug (10.254.254.254 Trick)
View README.md

Docker (Mac) De-facto Standard Host Address Alias

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

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
ralphschindler / Dockerfile
Created September 8, 2021 13:39
Build php xdebug from scratch in a Docker container, with laravel app
View Dockerfile
FROM ubuntu:20.10
RUN mkdir /app
WORKDIR /app
RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
apt-get install -qqy --no-install-recommends \
ca-certificates \
valgrind \
@ralphschindler
ralphschindler / .php_cs.dist
Created April 20, 2021 14:24
Generic PHP-CS-Fixer Rules
View .php_cs.dist
<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
->notName('.php_cs.dist');
return (new PhpCsFixer\Config)
->setFinder($finder)
->setRules([
@ralphschindler
ralphschindler / StringIsLengthRule.php
Last active April 19, 2021 19:21
Custom Dynamic Validation Rules for Laravel 5.5+
View StringIsLengthRule.php
<?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';
View nola.md

The 231 New Orleanians On Github

(Followers / Following in last column)

Ralph Schindler
@ralphschindler
ralphschindler / Dockerfile
Last active December 15, 2020 01:39
Dockerfile for setting up PHP 8 and xdebug to demonstrate an issue
View Dockerfile
FROM ubuntu:20.10
RUN mkdir /app
WORKDIR /app
RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
apt-get install -qqy --no-install-recommends \
ca-certificates \
valgrind \
@ralphschindler
ralphschindler / aop-uow-change-tracking.php
Last active November 22, 2020 04:03
A aop based Unit Of Work prototype/example with minimal code
View aop-uow-change-tracking.php
<?php
/**
* Foo is an Entity
*/
class Foo
{
protected $bar = 'original';
public function getBar()
@ralphschindler
ralphschindler / code-complete-stub-generator.php
Last active March 14, 2020 20:52
IDE code-completion stub generation script that utilizes reflection. (Primary use would be for extension stubs.)
View code-complete-stub-generator.php
<?php
define('T', ' ');
define('N', PHP_EOL);
$functions = array();
$classes = array();
$constant_prefix = 'X_';
$php = '<?php' . N;
@ralphschindler
ralphschindler / SnapshotCommand.php
Created July 11, 2019 20:26
An example Laravel app command to create and load database snapshots using S3
View SnapshotCommand.php
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Storage;
class SnapshotCommand extends Command
{