Skip to content

Instantly share code, notes, and snippets.

View davedevelopment's full-sized avatar
😬
I may be slow to respond.

Dave Marshall davedevelopment

😬
I may be slow to respond.
View GitHub Profile
/**
* The Application(which is an instance of Pimple) sets up it's required dependencies, one of which is a logger
*/
$this['logger'] = null;
/** snip */
/**
* The controller resolver takes an optional logger
*/
@davedevelopment
davedevelopment / gist:3701011
Created September 11, 2012 19:06
Migrating passwords to Symfony's Password encoder
<?php
use Symfony\Component\Security\Core\Encoder\MessageDigestPasswordEncoder as SyMessageDigestPasswordEncoder;
/**
* Used to allow for use of existing passwords that were just sha1 in the db,
*/
class Sha1MessageDigestPasswordEncoder extends SyMessageDigestPasswordEncoder
{
public function encodePassword($raw, $salt)
@davedevelopment
davedevelopment / gist:3273991
Created August 6, 2012 12:09
Run a whole feature or nearest scenario in vim
" Run behat features
function! RunFeature(...)
" Are we in a feature file?
let in_feature_file = match(expand("%"), '.feature$') != -1
let run_nearest_scenario = a:0
if in_feature_file
" if so, store the path for later
let t:dm_feature_file=@%
@davedevelopment
davedevelopment / gist:2884984
Created June 6, 2012 21:36
Print routes and where they're defined for a silex app
#!/usr/bin/env php
<?php
# bin/routes
$app = require __DIR__ . '/../app/bootstrap.php';
$routes = $app['routes']->all();
foreach($routes as $route) {
$cr = new ReflectionFunction($route->getDefault('_controller'));
@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
@davedevelopment
davedevelopment / index.php
Created March 28, 2012 08:11 — forked from igorw/index.php
Example of overriding service, without unnecessary loading
<?php
require_once __DIR__.'/vendor/.composer/autoload.php';
use Silex\Application;
$app = new Application;
$app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array(
@davedevelopment
davedevelopment / index.php
Created March 27, 2012 22:12
Example of overriding service, without unnecessary loading
<?php
require_once __DIR__.'/vendor/.composer/autoload.php';
use Silex\Application;
$app = new Application;
$app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array(
<?php
require __DIR__.'/vendor/.composer/autoload.php';
$app = new Silex\Application();
$app->register(new Silex\Provider\SessionServiceProvider());
$app['debug'] = true;
$app->get('/', function() use($app) {
@davedevelopment
davedevelopment / AudioNotifier.php
Created March 1, 2012 13:46
Audio notifier for Sismo
<?php
use Sismo\Notifier;
use Sismo\Commit;
/**
* A simple audio notifier for Sismo
*
* (c) Dave Marshall <dave.marshall@atstsolutions.co.uk>
*
@davedevelopment
davedevelopment / FailingTest.php
Created February 29, 2012 12:20 — forked from dmitrybelyakov/FailingTest.php
Bootstrap phpunit
<?php
require_once ('PHPUnit/Autoload.php');
class FailingTest extends \PHPUnit_Framework_TestCase
{
public function testTestThatWeJustFail()
{
$this->assertTrue(true);
}