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 / Module.php
Created February 5, 2014 16:15
Example of attaching to the "authenticate" event.
<?php
class Module
{
public function onBootstrap($e)
{
$app = $e->getApplication();
$services = $app->getServiceManager();
$events = $app->getEventManager();
$events->attach('authenticate', function ($e) use ($services) {
@weierophinney
weierophinney / rtut.zsh
Created February 11, 2014 20:17
PHPUnit test runner using inotifywait
#!/bin/zsh
#
# Copyright (c) 2014, Joshua Thijssen
# Copyright (c) 2014, Matthew Weier O'Phinney
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.

Keybase proof

I hereby claim:

  • I am weierophinney on github.
  • I am mwop (https://keybase.io/mwop) on keybase.
  • I have a public key whose fingerprint is 8D98 47CD E15F 050B 8197 6BA7 B545 7969 23ED 29DA

To claim this, I am signing this object:

@weierophinney
weierophinney / composer.json
Created April 23, 2014 18:38
Adding apigility deps to an existing repo
{
"name": "zendframework/skeleton-application",
"description": "Skeleton Application for ZF2",
"license": "BSD-3-Clause",
"keywords": [
"framework",
"zf2"
],
"homepage": "http://framework.zend.com/",
"require": {
@weierophinney
weierophinney / Module.php
Created May 7, 2014 20:13
Returning early if a specific HTTP header is missing
<?php
namespace SomeApi;
use ZF\ApiProblem\ApiProblem;
use ZF\ApiProblem\ApiProblemResponse;
class Module
{
public function onBootstrap($e)
{
@weierophinney
weierophinney / TableGatewayFeaturesDelegatorFactory.php
Last active August 29, 2015 14:01
delegator for injecting TableGateway features into TableGateways created as part of the Apigility DB-Connected functionality.
<?php
use Zend\Db\TableGateway\Feature;
use Zend\ServiceManager\DelegatorFactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class TableGatewayFeaturesDelegatorFactory implements DelegatorFactoryInterface
{
public function createDelegatorWithName(
ServiceLocatorInterface $services,
@weierophinney
weierophinney / OAuth2PdoAdapterFactory.php
Created August 5, 2014 20:13
Example of pulling a PDO connection from an existing ZF2 DB adapter in order to seed a ZF\OAuth2\Adapter\PdoAdapter instance.
<?php
use ZF\OAuth2\Adapter\PdoAdapter;
class OAuth2PdoAdapterFactory
{
public function __invoke($services)
{
$db = $services->get('DB\MyDbName');
if (! $db instanceof Adapter) {
@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

<?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 / 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.