Skip to content

Instantly share code, notes, and snippets.

@Ocramius
Ocramius / .gitignore
Last active July 22, 2017 15:20
PissOff: a valid, polite and useful alternative to the `void` return type in PHP
vendor
composer.lock
@faparicior
faparicior / CheckBoxImgType.php
Last active October 28, 2022 13:24
Symfony2 checkbox button images using choice form
<?php
namespace CheckInBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolver;
class CheckBoxImgType extends AbstractType
{
public function configureOptions(OptionsResolver $resolver)
@Ocramius
Ocramius / find-missing-return-types.php
Last active September 5, 2018 10:27
Script to find classes/interfaces/traits with missing return types: ADD THEM TO YOUR SHIT.
<?php
require_once __DIR__ . '/vendor/autoload.php';
$namespace = 'PutYourProjectNamespaceHere\\';
foreach (new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator(__DIR__ . '/src')), '/^.+\.php$/i', RecursiveRegexIterator::GET_MATCH) as $file) {
require_once $file[0];
}
@chalasr
chalasr / EnhancedRepository.php
Last active September 26, 2023 00:59
Implements a custom EntityRepository using Factory in Symfony2.6+
<?php
namespace App\Util\Doctrine\Repository;
use App\Util\Doctrine\Entity\AbstractEntity;
use Doctrine\Common\Persistence\ObjectRepository;
use Doctrine\ORM\EntityRepository;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException;
@natsu90
natsu90 / gist:6787b254929355c34e63
Last active March 27, 2024 21:54
Installing PDO Informix
1. Installing Informix Client SDK for Linux x86_64
1.1 Download Informix Client SDK 3.70 for Linux x86_64 from IBM website, https://www-01.ibm.com/marketing/iwm/tnd/search.jsp?rs=ifxdl
1.2 Extract the file, `cd /opt/informix; tar -xvf clientsdk.3.70.FC8DE.LINUX.tar`
1.3 Start installation, `./installclientsdk`, install all
2. Installing PDO Informix
<?php
namespace Acme\Serializer\Normalizer;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\Normalizer\SerializerAwareNormalizer;
@Thinkscape
Thinkscape / EffectiveUrlMiddleware.php
Last active October 4, 2022 18:30
getEffectiveUrl() replacement for Guzzle 6.*
<?php
namespace Thinkscape\Guzzle;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
class EffectiveUrlMiddleware
{
/**
* @var Callable
@maurizi
maurizi / ansible-galaxy.bat
Last active May 21, 2024 02:10
Running Ansible on Windows
@echo off
cygwin-shim.bat /bin/ansible-galaxy %*
@boekkooi
boekkooi / ConnectionKeepAlive.php
Last active October 19, 2023 23:17
Doctrine keep alive (MySQL server has gone away)
<?php
namespace Acme\Doctrine\DBAL;
use Doctrine\DBAL\Connection;
declare(ticks = 3000000);
class ConnectionKeepAlive
{
/**
@Ocramius
Ocramius / BlogPostHydrator.php
Last active August 17, 2017 11:50
Association lazy-loading with Zend\Db
<?php
use ProxyManager\Factory\LazyLoadingValueHolderFactory;
use Zend\Stdlib\Hydrator\HydratorInterface;
class BlogPostHydrator implements HydratorInterface
{
/**
* @var HydratorInterface
*/