Skip to content

Instantly share code, notes, and snippets.

@sasezaki
sasezaki / middleware.php
Created January 13, 2016 15:57
An Middleware Builder in a tweet
<?php
// Minified
// class B{function __construct($m){$this->m = $m;} function __invoke($req,$res) {if($this->m)return array_shift($this->m)($req,$res,$this);}}
class B{
function __construct($m)
{
$this->m = $m;
}
<?php
class TestClass
{
private $internalScalar;
public function __construct($arg)
{
$this->internalScalar = $arg;
}
@sasezaki
sasezaki / index.php
Last active December 28, 2015 23:59
to run under phpdbg & react, react-zf
<?php
/**
* This makes our life easier when dealing with paths. Everything is relative
* to the application root now.
*/
chdir(dirname(__DIR__));
// Decline static file requests back to the PHP built-in webserver
if (php_sapi_name() === 'cli-server' && is_file(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) {
return false;
@sasezaki
sasezaki / myphpdbg.init
Created November 16, 2013 12:59
function completion phpdbg.init
<:
readline_completion_function(function(){return array_merge(get_defined_functions()['internal'],array_keys(get_defined_constants()));});
:>
@sasezaki
sasezaki / scan.php
Created October 30, 2013 16:01
zf2-5384
diff --git a/library/Zend/Code/Scanner/PropertyScanner.php b/library/Zend/Code/Scanner/PropertyScanner.php
index 0ba37f6..0d7a49f 100644
--- a/library/Zend/Code/Scanner/PropertyScanner.php
+++ b/library/Zend/Code/Scanner/PropertyScanner.php
@@ -226,6 +226,7 @@ class PropertyScanner implements ScannerInterface
SCANNER_TOP:
$token = current($tokens);
+ $index = key($tokens);
@sasezaki
sasezaki / gist:6992409
Last active December 25, 2015 14:39
find slides includes keyword
php miffie.phar -x '//div[@id="talks"]//a[contains(text(), "Zend")]' -v @href http://joind.in/event/view/1493 | php miffie.phar -x '//p[@class="quicklink"]//parent::*[contains(normalize-space(text()), "Slides")]//a' -v @href -s -w 1 -
php miffie.phar -x '//div[@id="talks"]//a[contains(text(), "ZF2")]' -v @href http://joind.in/event/view/1493 | php miffie.phar -x '//p[@class="quicklink"]//parent::*[contains(normalize-space(text()), "Slides")]//a/parent::*' -v html -s -w 1 -
<?php
class Module
{
public function onBootstrap($event)
{
$events = $event->getTarget()->getEventManager();
$events->attach(MvcEvent::EVENT_FINISH, function($e) {
if ($match = $e->getRouteMatch()) {
$params = $match->getParams();
@sasezaki
sasezaki / config_autoload_simplepage.local.php
Created October 4, 2013 15:51
Automatic find page per route for PhlySimplePage.
<?php
class FilePerRouteIterator extends IteratorIterator
{
public function key()
{
return pathinfo(parent::key(), PATHINFO_FILENAME);
}
public function current()
<?php
use Zend\Console\Console;
use Zend\Console\Adapter\AdapterInterface as ConsoleAdapter;
use Zend\Console\ColorInterface as Color;
use Zend\Console\Request;
use Zend\Console\Response;
use Zend\Mvc\Router\Console\SimpleRouteStack;
use Zend\View\Variables;
use Zend\View\Model\ConsoleModel;
use Zend\View\Model\ViewModel;
@sasezaki
sasezaki / gist:6257841
Created August 17, 2013 17:13
buession make
/bin/bash /home/sasezaki/eduosi_buession/libtool --mode=compile cc -I. -I/home/sasezaki/eduosi_buession -DPHP_ATOM_INC -I/home/sasezaki/eduosi_buession/include -I/home/sasezaki/eduosi_buession/main -I/home/sasezaki/eduosi_buession -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/libxml2 -DHAVE_CONFIG_H -g -O2 -c /home/sasezaki/eduosi_buession/buession.c -o buession.lo
libtool: compile: cc -I. -I/home/sasezaki/eduosi_buession -DPHP_ATOM_INC -I/home/sasezaki/eduosi_buession/include -I/home/sasezaki/eduosi_buession/main -I/home/sasezaki/eduosi_buession -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/libxml2 -DHAVE_CONFIG_H -g -O2 -c /home/sasezaki/eduosi_buession/buession.c -fPIC -DPIC -