Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* MongoSessionStrage manages session storage via MongoDB
*
* This class stores the session data in via MongoDB and with an id issued in a
* signed cookie. Useful when you don't want to store the session.
*
* @package PHP
* @subpackage session
* @author Masao Maeda <brt.river@gmail.com>
@brtriver
brtriver / gist:978383
Created May 18, 2011 11:12 — forked from heavenshell/gist:978358
Silex error
<?php
require_once 'silex.phar';
$app = new Silex\Application();
$app->get('/', function () {
return 'index';
});
$app->get('/hello/{name}', function ($name) {
<?php
/*
こんなイメージ
(例) 1,1 と 1,2 に爆弾がある
x:1 x:2 x:3 x:4
+-----+-----+-----+-----+
y:1| x | | | |
+-----+-----+-----+-----+
@brtriver
brtriver / compile.php
Created January 21, 2012 17:01
Twig.git to twig.phar
<?php
$phar = new Phar('twig.phar', 0, 'twig.phar');
$phar->buildFromDirectory(__DIR__ . '/Twig.git/lib');
$phar->compressFiles(Phar::GZ);
$phar->setDefaultStub();
@brtriver
brtriver / BasicAuthControllerProvider.php
Created February 4, 2012 20:36
Simple Basic Auth Controller for Silex.
<?php
namespace Silex\Provider;
use Silex\Application;
use Silex\SilexEvents;
use Silex\ControllerProviderInterface;
use Silex\ControllerCollection;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
@brtriver
brtriver / index.php
Created March 18, 2012 08:48
silex with cookie
<?php
require __DIR__ .'/silex.phar';
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Cookie;
$app = new Silex\Application();
$app['debug'] = true;
@brtriver
brtriver / sample.php
Created March 30, 2012 01:20
What result do you expect?
<?php
date_default_timezone_set('Asia/Tokyo');
if (date('n', strtotime('this month')) === date('n', strtotime('last month'))) {
echo "never call";
}
// last month は前月の"同一日"を返そうとするので、
// 2月30日 -> 3月1日 のように解釈されてしまう。
// 前月の月を知りたい場合は 以下のようにfirst day of をつけないと先月が何月かを正確に取得できない!
@brtriver
brtriver / composer.json
Created June 8, 2012 14:34
routing php framework
{
"require": {
"symfony/routing": "2.1.*",
"symfony/http-foundation": "2.1.*",
"symfony/config": "2.1.*",
"symfony/yaml": "2.1.*",
"pimple/pimple": "dev-master"
}
}
@brtriver
brtriver / config
Created June 9, 2012 05:26
nginx + fastcgi + rewrite
server {
listen 80;
server_name php54.vm.localhost;
access_log /var/log/nginx/vm.localhost.access.log;
error_log /var/log/nginx/vm.localhost.error.log;
location / {
root /var/www/localhost/web;
index index.html index.htm;
@brtriver
brtriver / Guardfile
Last active October 16, 2018 09:05
testrunner with humcrest and doccomments
# More info at https://github.com/guard/guard#readme
guard 'shell' do
watch(/src\/(.*).php/) {|m| `php hamcrester.php #{m[0]}` }
end