Skip to content

Instantly share code, notes, and snippets.

Avatar

Ralph Schindler ralphschindler

View GitHub Profile
@ralphschindler
ralphschindler / README.md
Last active Jan 12, 2021
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)...

View nola.md

The 231 New Orleanians On Github

(Followers / Following in last column)

Ralph Schindler
@ralphschindler
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
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 Nov 22, 2020
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 Mar 14, 2020
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 / example.php
Created Oct 24, 2012
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 / SnapshotCommand.php
Created Jul 11, 2019
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
{
@ralphschindler
ralphschindler / AuthServiceProvider.php
Last active Apr 5, 2019
Laravel 5.8 Policy Guesser For Using "Models" Directory
View AuthServiceProvider.php
<?php
namespace App\Providers;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
class AuthServiceProvider extends ServiceProvider
{
/**
@ralphschindler
ralphschindler / SampleOAuth2Client.php
Created Nov 26, 2014
A Barebones OAuth2 PHP Client demonstrating the "Password Grant Type"
View SampleOAuth2Client.php
<?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
@ralphschindler
ralphschindler / array_walk_recursive_key.php
Created Sep 19, 2014
Apply user functions to both keys and values while recursively walking an associative array
View array_walk_recursive_key.php
<?php
function array_walk_recursive_key(array $array, callable $valueCallback, callable $keyCallback = null) {
foreach ($array as $n => &$v) {
$n2 = ($keyCallback) ? $keyCallback($n) : $n;
if ($n != $n2) {
$array[$n2] = &$array[$n];
unset($array[$n]);
}
if (is_array($v)) {