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
<?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"
@davedevelopment
davedevelopment / partial.php
Last active December 14, 2015 14:18
Partial application of call_user_func_array with pimple
<?php
function lazyProxyFactoryMethodFunctionPartialApplicationOfPimple($app, $id, $method)
{
return function() {
return call_user_func_array(array($app[$id], $method), func_get_args());
}
}
// test for diff
<?php
class FooConverter
{
public function convert($value) {}
}
$app = new Silex\Application;
$app['converters.foo'] = function($value) {
@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
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']);
<?php
namespace Dave {
class IsAce {}
}
namespace {
var_dump(class_exists('IsAce', false)); // bool(false)
}
@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
$app = include __DIR__.'/../app/bootstrap.php';
$app->run();
@davedevelopment
davedevelopment / tree
Created February 12, 2013 14:49
tree
.
├── app
├── bin
├── chef
├── data
├── docs
├── features
├── migrations
├── public
├── src