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 / need-help-with-component-split.md
Last active March 31, 2016 07:32
Please help me with a tricky git component split problem

UPDATE: I discovered the issue is with specifying a commit range to filter-branch. When that is omitted, everything works perfectly, including history truncation! Thanks to everyone who assisted with ideas and suggestions!

I am currently working on a project to split the various components of Zend Framework 2 into their own repositories.

Currently, our repository structure looks like this:

.coveralls.yml
.gitattributes
@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.
@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 / CallbackStream.php
Last active October 23, 2020 14:16
Examples of streams you can use for alternate output styles in PSR-7
<?php
/**
* @copyright Copyright (c) 2015 Matthew Weier O'Phinney (https://mwop.net)
* @license http://opensource.org/licenses/BSD-2-Clause BSD-2-Clause
*/
namespace Psr7Examples;
use Psr\Http\Message\StreamableInterface;
@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 / 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 / collection.php
Created November 24, 2014 16:02
Example of creating a collection with extra attributes.
<?php
$collection = new \ZF\Hal\Collection($actualCollectionUsuallyAPaginator);
$collection->setAttributes([
'name' => 'BQSLIB',
'description' => 'BQSLib',
'creationDate' => '2010-11-08 12:12:42',
]);
// Either add this as a property of the entity, or return it.
@weierophinney
weierophinney / QueryController.php
Created November 18, 2014 21:44
Example of embedding multiple collections in a HAL payload within Apigility.
<?php
/* We'll assume that all of the above classes are defined.
*
* We'll assume that Api\V1\Rpc\Query\QueryController will handle an RPC service
* call to /search?s=thing. It needs to be configured such that it responds to
* GET requests, and Content Negotiation is set to HalJson.
*
* This is what it will look like:
*/
<?php
function injectLogoLink($e)
{
$halEntity = $e->getParam('entity');
$halEntity->getLinks()->add(\ZF\Hal\Link\Link::factory(
'rel' => 'logo',
'route' => array(
'name' => 'cart-logo',
'params' => array(
'id' => $halEntity->id,
@weierophinney
weierophinney / response.md
Created October 9, 2014 21:17
A comment posted to blog.weblicious.net

In response to: http://blog.weblicious.net/2014/10/where-most-of-our-articles-are-coming-from/

The comment is currently marked as moderated; I don't expect it will be approved.


Then link directly to the original article, and indicate the original author. Feeds provide both of these pieces of information. Right now, ALL articles indicate they are written by Ali El Manini (though I will admit that many include the original author in the title, the author listed is Ali, in both the articles and the feed). NONE of them link back to the original — which is alone enough reason for people to ask that you stop republishing. Add on to this that many are clearly the truncated versions aggregated by Planet PHP (which PROPERLY attributes the original author and links back to the original article), there’s even less indication of how to find the original in order to get the full version.

At the very least, this site adds confusion to the google results for given topics. It definitely violates copyright by republ