Skip to content

Instantly share code, notes, and snippets.

Working from home during quarantine. In other words, just like always.

Matthew Weier O'Phinney weierophinney

Working from home during quarantine. In other words, just like always.
View GitHub Profile
weierophinney /
Last active Apr 24, 2021
How to prepare a PR to add the GHA CI workflow to Laminas/Mezzio/Laminas API Tools repos

PRs should do the following:

  • Remove the file (we will be doing changelogs in the milestone descriptions, and those get propagated to tags and release notes)

  • Add the workflow file:

    mkdir -p .github/workflows ; cd  .github/workflows ; wget
weierophinney / composer.json
Created Jun 4, 2020
Sample minimalist "mezzio" application (really just Stratigility + Mezzio routing)
View composer.json
"require": {
"laminas/laminas-stratigility": "^3.2",
"mezzio/mezzio-fastroute": "^3.0",
"laminas/laminas-diactoros": "^2.3",
"laminas/laminas-httphandlerrunner": "^1.2"
weierophinney / Dockerfile
Created Nov 1, 2018
Getting ext-tidy to work on alpine-based PHP images
View Dockerfile
FROM php:7.2-cli-alpine3.8
# Compile-time dependencies
RUN echo '' >> /etc/apk/repositories
RUN apk update && \
apk add --no-cache 'tidyhtml-dev==5.2.0-r1'
# Install the extension
weierophinney / UserCollection.php
Created Jun 5, 2018
Example of casting an array of entities to a collection
View UserCollection.php
namespace App\Entity;
use ArrayIterator;
class UserCollection extends ArrayIterator
weierophinney / index.html
Created May 31, 2018
Prototype for auto-populating the component dropdown and making it searchable.
View index.html
<!doctype html>
<html lang="en">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Choices example</title>
<link rel="stylesheet" href="" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
weierophinney / RemoveDevPrefixMiddleware.php
Created Sep 14, 2017
Demonstrates stripping a path prefix prior to routing.
View RemoveDevPrefixMiddleware.php
use Interop\Http\ServerMiddleware\DelegateInterface;
use Interop\Http\ServerMiddleware\MiddlewareInterface;
use Psr\Http\Message\ServerRequestInterface;
class RemoveDevPrefixMiddleware implements MiddlewareInterface
private $prefix;
weierophinney / Module.php
Created Aug 17, 2017
Demonstrates a zend-mvc listener that short-circuits, and how to register it
View Module.php
// In a module class somewhere...
use Zend\EventManager\LazyListener;
use Zend\Mvc\MvcEvent;
class Module
public function onBootstrap(MvcEvent $e)

[RFC] zend-expressive-router (and related) changes for Expressive 1.1.

Proposed zend-expressive-router changes include:

  • Adding a $path parameter to RouteResult::fromRouteMatch().

    What if instead we were to add a new static method, RouteResult::fromRoute(), and a new instance method, RouteResult::getRoute()? (as I have suggested in zendframework/zend-expressive#398)? This would allow consumers to then pull the path from the Route instead, and provide access to the path, name, allowed methods, options, etc. (e.g., $result->getRoute()->getPath())

    This could even be done in a new 1.3.0 minor release; users who depend on that new feature would need to update their project to pin to the new minor release or later; otherwise, everything continues working as normal.


[Expressive] RFC: Programmatic pipelines

When we originally created the API for Expressive, it was programmatic:

We had pipelines:

weierophinney /
Last active Oct 26, 2016
Proposal to implement PSR-15 in zend-stratigility

[zend-stratigility] RFC: Implement PSR-15

PSR-15 proposes a standard around PHP middleware that consumes PSR-7 HTTP message instances. One goal of the standard is to create interfaces that can co-exist with existing projects, which would allow adoption without necessarily leading to backwards compatibility breaks.

The most recent proposal has the following interfaces: