Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

BEAR (Suday) design

  • Login to see the comments

BEAR (Suday) design

  1. 1. BEAR (Sunday) PHP 5.3+ /5.4
  2. 2. 1. namespace
  3. 3. 1. namespaceuse couponAppAuth as couponAuth;use blogAppAuth as blogAuth;read ro:://coupon/User?id=1read ro:://blog/User?id=1
  4. 4. 2. DI
  5. 5. Say goodbye toBEAR::Dependency()
  6. 6. Say hello toBEARDi::Container();
  7. 7. ra .Di Au by redP owe
  8. 8. Dependency Injection the JSR 330 way DI
  9. 9. namespace BEARTestexampleAppLog;/** Singleton * BEAR * Prototype * @Scope("singleton") @Scope */ Sessionclass Log{ Application /** * Reource * * @Inject @Inject Property Injection * * @var Resource */ private $resource; /** * Di * * @Inject * * @var Di */ private $di; /** * Init
  10. 10. * * @var Di */private $di;/** * Init * * @PostConstruct @PostConstruct Initialization */public function onInit(){ $this->inited = true;}/** * @PreDestoroy @PreDestory Finalization */public function onEnd(){}/** * @Inject @Inject Setter Injection * * @param Db $db */public function setDb(Db $db){}
  11. 11. }/** * @PreDestoroy @PreDestory Finalization */public function onEnd(){}/** * @Inject @Inject Setter Injection * * @param Db $db */public function setDb(Db $db){}/** * @Inject * @Named("user=admin_user,db=test_db") @Named * * @param Db $db * */public function setDouble(User $user, Db $db){ $this->db = $db;}
  12. 12. 2. Annotation
  13. 13. •••
  14. 14. /** * Blog info * * @Template(user.tpl) * @Cache(life=0) Inversion of Control * @Pager(item=10) * @Pull(“ro://self/User/Login”) */public function onRead($values){ $this->set();} @Pull
  15. 15. 3.More Resource Oriented
  16. 16. App_Main::run($class);
  17. 17. App_Main::run($class);
  18. 18. $params = $di->get(‘params’)->setOption($option);$page = $di->factory(testappAppPageHelloWorld);$ro = $di->get(main)->request($page, $params)->getRo();$ro->output(); Ro
  19. 19. 3.Resource Interface
  20. 20. Page Rofunction request(Ro $ro, Params $params)function output(Ro $ro)
  21. 21. Page Rofunction request(Ro $ro, Params $params)
  22. 22. Page Rofunction request(Ro $ro, Params $params)
  23. 23. MainPage Page Ro function request(Ro $ro, Params $params) function output(Ro $ro)
  24. 24. PageAdapter::request(Ro $ro, Params $params);MainPage Page Ro function request(Ro $ro, Params $params) function output(Ro $ro)
  25. 25. PageAdapter::request(Ro $ro, Params $params);MainPage Page Ro function request(Ro $ro, Params $params) function output(Ro $ro)
  26. 26. mod_phpWeb Apache Page Ro Web Apache PHP
  27. 27. Resource Interface pageAdapter::request($page, $params); roAdapter::request($page, $params); read User?id=1 GET /User?id=1 request($page, $params); request($ro, $params);Browser Main Page Ro HTTP $ro $ro $ro->output(); Ro
  28. 28. •• Page Page
  29. 29. 4.CQRS
  30. 30. CQRSCommand and Query Responsibility Segregation
  31. 31. CQS: -Bertrand Meyer http://d.hatena.ne.jp/digitalsoul/20100712/1278886009
  32. 32. CQRS + REST = ?
  33. 33. CQS: DELETE UPDATE CREATE READ REST GET Side Effect FREE -Bertrand Meyer http://d.hatena.ne.jp/digitalsoul/20100712/1278886009 DDD/Side -Effect-Free Functions - Java EE
  34. 34. CQRS + REST = BEAR
  35. 35. NoSQL QUERY read User?id=1 <h2>koriym</h2> Client <ul> <li>name: Koriama</li> Representation </ul> COMMAND Resourceupdate User?id=1&name=koriym RDB (MySQL)
  36. 36. NoSQL QUERY read User?id=1Query Command Query Command <h2>koriym</h2>Command Query Client <ul> <li>name: Koriama</li> </ul> COMMAND PC ,iPhone AJAX ... update User?id=1&name=koriym RDB (MySQL)
  37. 37. 5.Compatibility
  38. 38. Compatibility• Saturday(for 5.2)• (=Shared nothing) A• Ro• ...
  39. 39. CM gtalk realtime observe GUI MVC 6.RealTime$this->set(‘user’, $user, ‘realtime’);$this->set(‘user’, $user, ‘ajax’); bi ted Or by red P owe
  40. 40. 7.Multi Language PHP Page Java ResourceObjective-C Client PHP Resource hr ift b y T we red Po
  41. 41. 8. Online editorfully supported di tor A ceE by red Powe
  42. 42. design memo athttps://gist.github.com/1111850

×