<?php
class Greetings extends AbstractObject
{
public function onGet($lang = 'en')
{
$this['greeting'] = $this->message[$lang];
return $this;
}
}
<?php
use ResourceInject;
$this->resource->get->uri('app://self/greetings')->withQuery(['lang' => 'ja'])->eager->request();
<?php
$this->bind('Doctrine\Common\Annotations')
->to('Doctrine\Common\Annotations\FileCacheReader')
->in(Scope::SINGLETON);
<?php
/**
* @Inject
*/
public function __construct(Annotations $reader)
{
$this->reader = $reader;
}
<?php
class WeekendBlocker implements MethodInterceptor
{
public function invoke(MethodInvocation $invocation)
{
$today = getdate();
if ($today['weekday'][0] === 'S') {
throw new \RuntimeException(
$invocation->getMethod()->getName() . " not allowed on weekends!"
);
}
return $invocation->proceed();
}
}
<?php
class RealBillingService implements BillingService
{
/**
* @WeekendBlock
*/
public function chargeOrder()
{
...
}
}
<?php
$this->bindInterceptor(
$this->matcher->any(),
$this->matcher->annotatedWith('WeekendBlock'),
[new WeekendBlocker]
);
Rahter than reinvent the wheel and develop our library, BEAR.Sunday use (or will use) these great libraries.
-
Pagerfanta
- php 5.4
- APC
apc.enable_cli = 1
xhprof.output_dir = /tmp
Here's how to install BEAR.Sunday:
$ git clone git://github.com/koriym/BEAR.Sunday.git
$ cd BEAR.Sunday
$ wget http://getcomposer.org/composer.phar
$ php ./composer.phar install
$ chmod -R 777 apps/sandbox/tmp apps/sandbox/log
$ cd apps/sandbox/htdocs
$ php -S localhost:8088 web.php
$ curl http://localhost:8088/
$ php -S localhost:8089 api.php
$ curl http://localhost:8089/blog/posts
$ php web.php get /index
$ php api.php get app://self/greetings?lang=ja
$ php api.php get app://self/greetings?lang=en
$ php api.php get page://self/index