Skip to content

Instantly share code, notes, and snippets.

View gunnarlium's full-sized avatar

Gunnar Lium gunnarlium

View GitHub Profile
@gunnarlium
gunnarlium / keybase.md
Created August 16, 2016 10:34
keybase.md

Keybase proof

I hereby claim:

  • I am gunnarlium on github.
  • I am gunnarlium (https://keybase.io/gunnarlium) on keybase.
  • I have a public key ASDVYc_KW1M2rBQhbI1dAsPyCQ-Sb1CevXPL5Xoh_XD9fAo

To claim this, I am signing this object:

@gunnarlium
gunnarlium / guzzle-retry.php
Created December 17, 2015 16:23
Example of how to create a retry subscriber for Guzzle 6
<?php
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Handler\CurlHandler;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Psr7\Request as Psr7Request;
use GuzzleHttp\Psr7\Response as Psr7Response;
use Psr\Log\LoggerInterface;
const MAX_RETRIES = 2;
<?php
namespace App\Form\DataTransformer;
use Symfony\Component\Form\DataTransformerInterface;
class ArrayToStringTransformer implements DataTransformerInterface
{
public function transform($value)
{
@gunnarlium
gunnarlium / JsonErrorHandler.php
Last active September 20, 2018 12:47
Exmple JsonErrorHandler for Silex (or any other app implementing HttpKernel)
<?php
namespace Aptoma;
use Silex\Application;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\HttpException;
/**
* JsonErrorHandler is able to capture exceptions and do smart stuff with them.
@gunnarlium
gunnarlium / CorsEventSubscriber.php
Created June 21, 2013 20:17
Example of how to add CORS support in Silex, based on https://github.com/nelmio/NelmioCorsBundle.
<?php
namespace App\Event;
use Nelmio\CorsBundle\EventListener\CorsListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\KernelEvents;
class CorsEventSubscriber extends CorsListener implements EventSubscriberInterface
@gunnarlium
gunnarlium / composer.json
Created May 10, 2013 09:22
Guzzle\Log\MessageFormatter issue. Check output in guzzle.log.
{
"require": {
"guzzle/guzzle": "3.4.1",
"monolog/monolog": "~1.5"
}
}