Talkaboutlithium

1,273 views

Published on

lithium for cakephpher
authored by noppoMan722

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,273
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Talkaboutlithium

    1. 1. talk about lithium cakephper lithium 2012/01/06
    2. 2. lithiumpostlithium
    3. 3. noppoman722:23 java
    4. 4. cakephp Nate Abele cake phpFW cakephp3.0 cakephpphp5.3 ( static call ) mongoDB CouchDB 0.10 6
    5. 5. 2 git cloneli3 (cake bake) http://sourceforge.net/projects/li3/files/ lithium webroot
    6. 6. webrootli3http://koo.moo.jp/blog/2010/10/24/lithium-tutorial-1/
    7. 7. lithium(http://localhost/lithium/)
    8. 8. lthium
    9. 9. resouce (log templates )DB (cake routes)DB ( )mysql mongoDB CouchDB sqlite3 ( )Apc File Memcache Memory Redis XCache DBDB MongoDB APC(*apc )mongoMac : http://d.hatena.ne.jp/yohxx/20110130/1296396115Cent OS : http://blog.mamemomonga.com/item/460
    10. 10. POST
    11. 11. database configuration app/lithium/bootstrap/connections.php //mongoDB setting Connections::add(‘dev_mongo’ , array( ‘type’ => ‘MongoDb’ , ‘host’ => ‘localhost’ , ‘database’ => ‘posts’ ));cake
    12. 12. modelapp/models/Post.php<?phpnamespace appmodels;class Post extends lithiumdataModel {}lithium model
    13. 13. controllerapp/controllers/PostsController.phpnamespace appcontrollers; ← (java package )use appmodelsPost; ← (java import )class PostsController extends lithiumactionController { ← public function index() {! $posts = Post::all(); ←MongoDB post! return compact(posts); } public function add() {! $success = false;! if ($this->request->data) {! $post = Post::create($this->request->data);! $success = $post->save();! }! return compact(success); }}
    14. 14. viewapp/views/posts/index.html.php ( )<?php foreach($posts as $post): ?> <article> <h1><?=$post->title ?></h1> <p><?=$post->body ?></p> </article><?php endforeach; ?><?=$this->html->link(add,/posts/add); ?>app/views/posts/post.html.php<?php if ($success): ?><p>Post Successfully Saved</p><?php endif; ?><?=$this->form->create(); ?> <?=$this->form->field(title);?> <?=$this->form->field(body, array(type => textarea));?> <?=$this->form->submit(Add Post); ?><?=$this->form->end(); ?><?=$this->html->link(index,/posts/index); ?>twig smarty cake cake
    15. 15. MVC (http://localhost/posts/index)
    16. 16. POST! $post = Post::create($this->request->data); lithiumdataentityDocument $post->save(); (json mongo ) mongo
    17. 17. mongo
    18. 18. MongoDB
    19. 19. cake php controller render ( ) Component DB view .ctp .html.php Cool (cake ww) cake
    20. 20. lithium
    21. 21. lithium Chain of Respnsibility lithiumlithiumChain of RespnsibilityJ2EE SERVLET Filter (wiki)http://ja.wikipedia.org/wiki/Chain_of_Responsibility_%E3%83%91%E3%82%BF%E3%83%BC%E3%83%B3
    22. 22. FilterlithiumactionDispatcher::applyFilter()app/webroot/index.php<?php//loglithiumanalysisLogger::config(array(default => array(adapter => File)));$debugMessage = __FUNCTION__ . __LINE__;lithiumactionDispatcher::applyFilter(run,! function($self, $params, $chain) use ($debugMessage) {! ! lithiumanalysisLogger::debug($debugMessage); //! ! $res = $chain->next($self, $params, $chain); //! ! return $res;! });echo lithiumactionDispatcher::run(new lithiumactionRequest());(lithiumcoreStaticObject::$_methodFilters keyDispatcher::run )lithiumhttp://www.1x1.jp/blog/2010/10/lithium_filter_system.html
    23. 23. cake controller
    24. 24. renderlithiumactionController.phpprotected $_render = array( ! ! type => null, ! ! data => array(), ! ! auto => true, ! ! layout => default, ! ! template => null, ! ! hasRendered => false, ! ! negotiate => false ! );cake $this->layout $this->autoRenderlithiumactionController->render()
    25. 25. $this->autoRender = false;$this->layout = ‘default’;$this->set(‘key’,‘val’); lithium$this->render(array(‘auto’ => false, ‘layout’ => ‘default’, ‘data’ =>compact(‘hogehoge’)));
    26. 26. cakephp beforeFiter() _init() uses helpers components log $this->log lithiumanalysisLogger::debug()* cake AppController.php AppController.php $this->log()
    27. 27. cake model
    28. 28. controllercakephp$this->primaryKey = “hogehoge”;$this->useDbConfig = “sample”;lithium$this->config(‘key’ => ‘hogehoge’, ‘connection’ => ‘sample’);$_meta config()*primarykey id
    29. 29. mysqlapp/config/bootstrap/connections.phpConnections::add(“dev_mysql_master” , array( ‘type‘ => ‘database’ , ‘adapter‘ => ‘Mysql’ , ‘host‘ => ‘localhost’ , ‘login‘ => ‘user’ , ‘password’ => ‘pass’ , ’database’ => ‘sampledb’ ));app/models/hogehoge.php$this->config(‘key’ => ‘hogehoge’, ‘connection’ => ‘dev_mysql_maseter’); ← Mysqlpublic static function getAll(){ function args(){ $fields = array(‘id’, ‘title’); $condtions = array(‘id’ => 10); $offset = 3; $order = array(‘created’ => ‘desc’); return compact(fields, conditions, limit, offset, order) }; return lithiumdataModel::find(all, $args())->to(array);}
    30. 30. cakephp beforeFiter() _init() model static Mysql PEAR mysql (PDO mysqli ) $this->query()$db = Connections::get($self::meta(connection)); //$db->read(SELECT * FROM post, array(return => array)); 
    31. 31. model AppModel.php AppModel.php_init() mysql mongo
    32. 32. cakephp5.3mongo couchDB staticObject

    ×