Skip to content

Instantly share code, notes, and snippets.

Avatar
☢️
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
weierophinney / laminas-gha.md
Last active Apr 24, 2021
How to prepare a PR to add the GHA CI workflow to Laminas/Mezzio/Laminas API Tools repos
View laminas-gha.md

PRs should do the following:

  • Remove the CHANGELOG.md 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 https://gist.githubusercontent.com/weierophinney/9decd19f76b7d9745c6559074053fa65/raw/6ffb33e59796cfec569405139aa65da9396ea5cd/continuous-integration.yml
@weierophinney
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
weierophinney / Dockerfile
Created Nov 1, 2018
Getting ext-tidy to work on alpine-based PHP images
View Dockerfile
# DOCKER-VERSION 1.3.2
FROM php:7.2-cli-alpine3.8
# Compile-time dependencies
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.6/community' >> /etc/apk/repositories
RUN apk update && \
apk add --no-cache 'tidyhtml-dev==5.2.0-r1'
# Install the extension
@weierophinney
weierophinney / UserCollection.php
Created Jun 5, 2018
Example of casting an array of entities to a collection
View UserCollection.php
<?php
namespace App\Entity;
use ArrayIterator;
class UserCollection extends ArrayIterator
{
}
@weierophinney
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">
<head>
<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="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
@weierophinney
weierophinney / RemoveDevPrefixMiddleware.php
Created Sep 14, 2017
Demonstrates stripping a path prefix prior to routing.
View RemoveDevPrefixMiddleware.php
<?php
use Interop\Http\ServerMiddleware\DelegateInterface;
use Interop\Http\ServerMiddleware\MiddlewareInterface;
use Psr\Http\Message\ServerRequestInterface;
class RemoveDevPrefixMiddleware implements MiddlewareInterface
{
private $prefix;
@weierophinney
weierophinney / Module.php
Created Aug 17, 2017
Demonstrates a zend-mvc listener that short-circuits, and how to register it
View Module.php
<?php
// In a module class somewhere...
use Zend\EventManager\LazyListener;
use Zend\Mvc\MvcEvent;
class Module
{
public function onBootstrap(MvcEvent $e)
{
View rfc-expressive-router-1.1.md

[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.

View rfc-expressive-programmatic.md

[Expressive] RFC: Programmatic pipelines

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

We had pipelines:

$pipeline->pipe($loggingMiddleware);
$pipeline->pipe($serverUrlHelperMiddleware);
$pipeline->pipeRoutingMiddleware();
@weierophinney
weierophinney / readme.md
Last active Oct 26, 2016
Proposal to implement PSR-15 in zend-stratigility
View readme.md

[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: