Skip to content

Instantly share code, notes, and snippets.

View koriym's full-sized avatar

Akihito Koriyama koriym

View GitHub Profile
@koriym
koriym / file0.php
Last active August 29, 2015 13:56
PHPの簡単ベンチマーク ref: http://qiita.com/koriym/items/0c8987faecc2782f2c8a
$time = microtime(true);
register_shutdown_function(
function() use ($time) {
printf("Memory: %s / %s bytes\nTime: %f ms\nDeclared: %d classes\nIncluded: %d files > include_files.txt\n",
number_format(memory_get_usage()),
number_format(memory_get_peak_usage()),
(microtime(true) - $time) * 1000,
count(get_declared_classes()),
count(get_included_files())
);
@koriym
koriym / hellworld.txt
Created February 5, 2014 16:21
minified BEAR.Sunday Demo.Helloworld app
<?php
namespace Ray\Di { interface InstanceInterface { public function getInstance($class); } } namespace Ray\Di { use Doctrine\Common\Cache\Cache; interface InjectorInterface extends InstanceInterface { public function getContainer(); public function getModule(); public function setModule(AbstractModule $module); public function getLogger(); } } namespace Ray\Di { use Aura\Di\ContainerInterface; use Aura\Di\Lazy; use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Annotations\AnnotationRegistry; use Doctrine\Common\Annotations\CachedReader; use Doctrine\Common\Cache\Cache; use LogicException; use Ray\Aop\Bind; use Ray\Aop\BindInterface; use Ray\Aop\Compiler; use Ray\Aop\CompilerInterface; use Ray\Di\Exception; use ReflectionClass; use ReflectionException; use ReflectionMethod; use SplObjectStorage; use ArrayObject; use PHPParser_PrettyPrinter_Default; use Serializable; use Ray\Di\Di\Inject; class Injector implements InjectorInterface, \Serializable { protected $config; protected $container;
@koriym
koriym / helloworld-app.txt
Last active August 29, 2015 13:56
BEAR.Sunday Demo.Helloworld app instance
O:19:"Demo\Helloworld\App":1:{s:8:"resource";O:22:"BEAR\Resource\Resource":8:{s:31:"BEAR\Resource\Resourcefactory";O:21:"BEAR\Resource\Factory":1:{s:29:"BEAR\Resource\Factoryscheme";C:30:"BEAR\Resource\SchemeCollection":11410:{x:i:0;a:3:{s:4:"page";a:1:{s:4:"self";O:25:"BEAR\Resource\Adapter\App":3:{s:35:"BEAR\Resource\Adapter\Appinjector";C:15:"Ray\Di\Injector":10729:{a:7:{i:0;O:16:"Ray\Di\Container":6:{s:8:"*forge";O:12:"Ray\Di\Forge":1:{s:9:"*config";O:13:"Ray\Di\Config":5:{s:9:"*params";C:11:"ArrayObject":35:{x:i:0;a:1:{s:1:"*";a:0:{}};m:a:0:{}}s:9:"*setter";C:11:"ArrayObject":35:{x:i:0;a:1:{s:1:"*";a:0:{}};m:a:0:{}}s:10:"*unified";a:0:{}s:13:"*definition";C:17:"Ray\Di\Definition":386:{x:i:0;a:8:{s:5:"Scope";s:9:"Prototype";s:13:"PostConstruct";N;s:10:"PreDestroy";N;s:6:"Inject";a:0:{}s:13:"ImplementedBy";a:0:{}s:4:"user";a:0:{}s:8:"optional";a:0:{}s:1:"*";a:0:{}};m:a:1:{s:27:"Ray\Di\Definitiondefaults";a:7:{s:5:"Scope";s:9:"Prototype";s:13:"PostConstruct";N;s:10:"PreDestroy";N;s:6:"Inject";a:0:{}s:13:"Im
@koriym
koriym / bear-bs.css
Created April 4, 2014 02:48
lessc prefixed.less > bear-bs.css
.bearsunday {
/*!
* Bootstrap v3.1.1 (http://getbootstrap.com)
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
/*! normalize.css v3.0.0 | MIT License | git.io/normalize */
/*# sourceMappingURL=bootstrap.css.map */
}
.bearsunday html {
@koriym
koriym / gist:490adf441037bae0167f
Created September 13, 2014 03:24
Ray.Di car example
<?php
use Ray\Di\ProviderInterface;
use Ray\Di\Di\Inject;
interface CarInterface{}
interface CarConfigInterface{}
class CarConfig extends \ArrayObject implements CarConfigInterface{}

Ray.Di v2

  • BC Break ?
  • Parameter injection in v2.x ?

BEAR.Sunday 1.0alpha

  • min
  • MinPackage (router + resource + json)
// original
$this['events'] = $this->resource->get->uri('app://spout/resources/listing')
->withQuery([
'type' => 'event',
'sort' => 'datetime'
])
->eager
->request()['resources'];
// link
@koriym
koriym / gist:6cdb82fe5ebf8fe219bd
Last active August 29, 2015 14:11
Syntax suger of get request
/**
* @param string|Uri $uri
* @param array $query
*
* @return callable
*/
function resource($uri, array $query)
{
$resource = (new Injector(new AppModule, __DIR__ . '/tmp'))->getInstance(ResourceInterface::class);
$request = $resource->get->uri($uri)->withQuery($query)->eager->request();
@koriym
koriym / gist:0933973ce159f71575a2
Created January 13, 2015 05:55
Router interface
Aura v2 https://github.com/auraphp/Aura.Router/blob/d50ad32e20409bd7fc8522dc81bf220b35c974aa/src/Router.php
public function match($path, array $server = array())
Symfony http://api.symfony.com/2.0/Symfony/Component/Routing/RouterInterface.html
public array match(string $pathinfo);
ZF2 http://framework.zend.com/manual/current/en/modules/zend.mvc.routing.html
public function match(Request $request);
PHP-Router https://github.com/dannyvankooten/PHP-Router/blob/master/src/PHPRouter/Router.php#L72
@koriym
koriym / gist:d45133f50941d3803772
Created April 21, 2015 03:54
最初のDependencyCompilerTest
<?php
namespace Ray\Di;
use Ray\Aop\Compiler;
use Ray\Aop\Matcher;
use Ray\Aop\Pointcut;
use Ray\Aop\WeavedInterface;
class DependencyCompilerTest extends \PHPUnit_Framework_TestCase