Skip to content

Instantly share code, notes, and snippets.

View marijn's full-sized avatar

Marijn Huizendveld marijn

View GitHub Profile
@everzet
everzet / autoload.php
Created July 24, 2012 14:29
app/autoload.php for Behat 2.4+ & Symfony2.1+
<?php
use Doctrine\Common\Annotations\AnnotationRegistry;
if (!class_exists('Composer\\Autoload\\ClassLoader', false)) {
$loader = require __DIR__.'/../vendor/autoload.php';
} else {
$loader = new Composer\Autoload\ClassLoader();
$loader->register();
}
@avalanche123
avalanche123 / timeout.php
Created July 10, 2012 19:12
timeouts in php
<?php
class TimeoutException extends RuntimeException {}
class Timeout
{
private $active;
public function set($seconds)
{
@beberlei
beberlei / .gitignore
Created May 31, 2012 10:01
Symfony Form PropertyPath for DataMapping
vendor
@peterjmit
peterjmit / deploy.rb
Created April 10, 2012 13:45
Create a parameters.ini file interactively when deploying with capifony
# This custom task for deploying a Symfony 2 application is set to run after deploy:setup
# is executed. It interactively ask a user for database details to create a parameters.ini
# thus avoiding having to manually on to the server and create it
#
# Helper function from http://stackoverflow.com/a/1662001/1041885
#
# Interactive parameter.ini generation adapted from http://adurieux.blogspot.co.uk/2011/10/using-capistrano.html
# ...
# ... Your deployment settings/tasks
@davedevelopment
davedevelopment / generate_classmap.sh
Created March 29, 2012 15:56
Hacky way of populating composer classmap
#!/bin/bash
perl -pi -e 's/array\(/array\(___CLASSLIST___,\n/' vendor/.composer/autoload_classmap.php
phpab -n -t vendor/.composer/autoload_classmap.php -o vendor/.composer/autoload_classmap.php -b `pwd`/vendor/.composer/ --tolerant vendor/
perl -pi -e 's/array\(/array\(___CLASSLIST___,\n/' vendor/.composer/autoload_classmap.php
phpab -n -t vendor/.composer/autoload_classmap.php -o vendor/.composer/autoload_classmap.php -b `pwd`/vendor/.composer/ --tolerant src/
perl -pi -e "s/'\/\.\./\\\$vendorDir.'/" vendor/.composer/autoload_classmap.php
@marijn
marijn / README.markdown
Created March 20, 2012 16:10
Finite state machine for locks
@jmikola
jmikola / RouterRequestContextPass.php
Created March 6, 2012 07:47
A cure for "localhost" appearing in absolute URL's when rendering a template from the Symfony2 CLI
<?php
namespace Application\ExerciseBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
/**
* Overrides the default host for the Router's RequestContext service.
*
@niepi
niepi / osx_php_homebrew.setup.md
Created February 28, 2012 13:23
OSX PHP Homebrew Setup

install php

with mysql pgsql intl support

$ brew install php --with-apache --with-mysql --with-pgsql --with-intl

set php timezone in php ini

date.timezone = Europe/Vienna
<?php
final class BlogPost
{
private $created;
private $publish;
public function __construct()
{
$this->created = new DateTime('now');
@edorian
edorian / clean-use.php
Created February 3, 2012 08:56 — forked from lapistano/clean-use.php
Script to clean unnecessary PHP use statements
#!/usr/bin/env php
<?php
$paths = array();
if (isset($_SERVER['argv']))
{
$paths = $_SERVER['argv'];
array_shift($paths);
if (!$paths)