Skip to content

Instantly share code, notes, and snippets.

View ralphschindler's full-sized avatar

Ralph Schindler ralphschindler

View GitHub Profile
@ralphschindler
ralphschindler / xdebug.sh
Created February 9, 2024 16:20
Enable/Disable Xdebug Via CLI Script
#!/bin/bash
QUIET=0
restart_php_fpm () {
if [ $QUIET -eq 1 ]; then
sv restart php-fpm > /dev/null
else
sv restart php-fpm
fi
@ralphschindler
ralphschindler / example.php
Created October 24, 2012 23:18
Zend\Db\Sql\Select example usage
<?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)

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
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
<?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+
<?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';

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
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
<?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.)
<?php
define('T', ' ');
define('N', PHP_EOL);
$functions = array();
$classes = array();
$constant_prefix = 'X_';
$php = '<?php' . N;