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
@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'));
$app->register(
new Silex\Provider\SwiftmailerServiceProvider(),
array(
'swiftmailer.options' => array(
'sender_address' => $sender,
'transport' => 'smtp',
'encryption' => null,
'auth_mode' => 'login',
'host' => $server,
'port' => $port',
<?php
require "vendor/autoload.php";
$mock = Mockery::mock("Dave")->shouldReceive("doThis")->once();
Mockery::close();
@davedevelopment
davedevelopment / DoctrineManagerRegistry.php
Created June 3, 2013 21:34
My doctrine manager registry
<?php
namespace Childcare\Common;
use Doctrine\Common\Persistence\AbstractManagerRegistry;
use Doctrine\ORM\ORMException;
use Pimple;
class DoctrineManagerRegistry extends AbstractManagerRegistry
{
$app['repository.factory'] = $app->protect(function($class) use ($app) {
return $app->share(function ($app) use ($class) {
return new $class($app['db']);
});
});
$app['users'] = $app['repository.factory']("User");
$app['groups'] = $app['repository.factory']("Groups");
@davedevelopment
davedevelopment / test.php
Created May 1, 2013 20:51
Listener removing itself
<?php
require "vendor/autoload.php";
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\Event;
$dispatcher = new EventDispatcher;
$eventName = 'dave';
@davedevelopment
davedevelopment / RESULTS
Last active December 15, 2015 22:49 — forked from igorw/RESULTS
Pimple
273K
2153K
0.009068s
DependencyInjection
275K
2903K
0.051517s
DependencyInjection (dumped)
2041K
<?php
$app->register(new Silex\Provider\TwigServiceProvider(), array(
'twig.path' => __DIR__.'/views',
'twig.options' => array(
'cache' => __DIR__.'/../data/cache/twig',
'auto_reload' => true,
'strict_variables' => false,
),
));
language: php
env:
- SYMFONY_DEPS_VERSION=2.1
- SYMFONY_DEPS_VERSION=2.2
before_script:
# symfony/*
- sh -c "if [ '$SYMFONY_DEPS_VERSION' = '2.2' ]; then sed -i 's/>=2.1,<2.3-dev/2.2.*@dev/g' composer.json; composer require --no-update 'symfony/property-access:2.2.*@dev'; composer update --dev --prefer-source; fi"
- sh -c "if [ '$SYMFONY_DEPS_VERSION' = '2.1' ]; then sed -i 's/>=2.1,<2.3-dev/2.1.*@dev/g' composer.json; composer update --dev --prefer-source; fi"
<?php
class FooConverter
{
public function convert($value) {}
}
$app = new Silex\Application;
$app['converters.foo'] = function($value) {