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 / RussianDependencyRoulettePimple.php
Created January 7, 2013 15:42
RussianDependencyRoulettePimple
<?php
class RussianDependencyRoulettePimple extends Pimple
{
public function offsetGet($id)
{
return parent::offsetGet(reset(shuffle($this->keys())));
}
}
<?php
/**
* Ideas for parameter converters
*
* I've used the word argument here rather than convert or converter,
* because there may not be any converting as such. It may be that things are
* plucked out of the request etc
*
* The idea being that some of the controller arguments come from the url,
#!/usr/bin/env php
<?php
$app = require __DIR__ . '/../app/bootstrap.php';
$routes = $app['routes']->all();
$data = array();
foreach($routes as $route) {
@davedevelopment
davedevelopment / tree
Created February 12, 2013 14:49
tree
.
├── app
├── bin
├── chef
├── data
├── docs
├── features
├── migrations
├── public
├── src
<?php
$app = include __DIR__.'/../app/bootstrap.php';
$app->run();
@davedevelopment
davedevelopment / Route.php
Created February 13, 2013 15:54
__call on Route to set whatever metadata I want
<?php
public function __call($name, array $args)
{
$this->setOption('_' . $name, $args);
return $this;
}
<?php
namespace Dave {
class IsAce {}
}
namespace {
var_dump(class_exists('IsAce', false)); // bool(false)
}
diff --git a/silex/app.php b/silex/app.php
index c72525c..172d4a1 100644
--- a/silex/app.php
+++ b/silex/app.php
@@ -16,8 +16,6 @@ $app = new Application();
*/
$app['locale'] = 'en';
$app['session.default_locale'] = $app['locale'];
-$app['translator.messages'] = require __DIR__ . '/resources/locales/translations.php';
-$app['languages'] = array_keys($app['translator.messages']);
@davedevelopment
davedevelopment / run_tests_against.sh
Created March 6, 2013 13:31
Attempt at a little test runner for silex
#!/bin/zsh
autoload colors
colors
function test_version() {
echo "Attempting to test against Symfony $1"
git reset HEAD --hard
<?php
class FooConverter
{
public function convert($value) {}
}
$app = new Silex\Application;
$app['converters.foo'] = function($value) {