Skip to content

Instantly share code, notes, and snippets.

View 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 Dec 17, 2015
Example of how to create a retry subscriber for Guzzle 6
View guzzle-retry.php
<?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;
View ArrayToStringTransformer.php
<?php
namespace App\Form\DataTransformer;
use Symfony\Component\Form\DataTransformerInterface;
class ArrayToStringTransformer implements DataTransformerInterface
{
public function transform($value)
{
@gunnarlium
gunnarlium / JsonErrorHandler.php
Last active Sep 20, 2018
Exmple JsonErrorHandler for Silex (or any other app implementing HttpKernel)
View JsonErrorHandler.php
<?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 Jun 21, 2013
Example of how to add CORS support in Silex, based on https://github.com/nelmio/NelmioCorsBundle.
View CorsEventSubscriber.php
<?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
Guzzle\Log\MessageFormatter issue. Check output in guzzle.log.
View composer.json
{
"require": {
"guzzle/guzzle": "3.4.1",
"monolog/monolog": "~1.5"
}
}