Skip to content

Instantly share code, notes, and snippets.

View weierophinney's full-sized avatar
⏯️

Matthew Weier O'Phinney weierophinney

⏯️
View GitHub Profile
@weierophinney
weierophinney / index.php
Created January 20, 2015 14:38
Conduit examples
<?php
use Phly\Conduit\Middleware;
use Phly\Conduit\FinalHandler;
use Phly\Conduit\Http\Request as RequestDecorator;
use Phly\Conduit\Http\Response as ResponseDecorator;
use Phly\Http\Response;
use Phly\Http\Server;
use Phly\Http\ServerRequestFactory;
require __DIR__ . '/../vendor/autoload.php';
@weierophinney
weierophinney / anonymous_middleware.php
Created February 24, 2015 18:35
Potential use case for anonymous PHP classes to translate between middleware types
<?php
$conduit->pipe(new class implements MiddlewareInterface {
public function __invoke($request, $response, $next)
{
$laravelRequest = mungePsr7ToLaravelRequest($request);
$laravelNext = function ($request) use ($next, $response) {
$request = ;
return $next(mungeLaravelToPsr7Request($request), $response)
};
$laravelMiddleware = new SomeLaravelMiddleware();
@weierophinney
weierophinney / CompositeAdapter.php
Created April 23, 2015 20:08
Example of a composite authentication adapter for zf-mvc-auth
<?php
use Zend\Http\Request;
use Zend\Http\Response;;
use ZF\MvcAuth\Authentication\AdapterInterface;
use ZF\MvcAuth\Identity\IdentityInterface;
use ZF\MvcAuth\MvcAuthEvent;
class CompositeAdapter implements AdapterInterface
{
private $adapters = [];
@weierophinney
weierophinney / summary.md
Created May 4, 2015 21:54
Summary of PSR-7 changes since Review 2 began.

Summary of changes since Review 2 Started

  • Expanded section on expected structure returned by getUploadedFiles(), with several examples ranging from a flat structure to a nested structure with a collection of files.
  • Clarifications and simplification of URI -> Host header interactions.
    • Updated withUri() to indicate it MUST update the Host header with the value present in the URI provided (if any) UNLESS the $preserveHost flag is boolean true.
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
@weierophinney
weierophinney / gist:1168465
Created August 24, 2011 16:30
Simple parser
$sxl = new SimpleXMLElement($url, 0, true);
$item = $sxl->item[0];
$link = (string) $item->link;
@weierophinney
weierophinney / gist:1348598
Created November 8, 2011 18:13
Prototype of module initialization listener system
<?php
interface Installable
{
public function install();
}
interface Upgradable
{
public function upgrade();
}
interface ConfigProvider
<?php
public function loadModule($moduleName)
{
if (!isset($this->loadedModules[$moduleName])) {
$class = $moduleName . '\Module';
$module = new $class;
$this->runModuleInit($module);
$this->mergeModuleConfig($module);
$this->loadedModules[$moduleName] = $module;
#!/bin/bash
# -------------------------------------------------------------
# Run phpUnit tests for a subset of Zend Framework
# -------------------------------------------------------------
# Author: Enrico Zimuel (enrico@zend.com)
# -------------------------------------------------------------
ZFPATH="/home/matthew/git/zf-standard/tests"
PHP="/home/matthew/svn/phpfarm/inst/bin/php-5.2.17"
PHPUNIT="/home/matthew/Downloads/dev/phpunit-3.4/phpunit/phpunit.php"