Lithium labo #2
Super Rad Framework




       2010/07/30 php-study tokkyo yandod
                                            1
Who am I

name Yusuke Ando
a,k,a, yando
Talking & Writing
 in JP PHP community
Rakuten.inc
Linkshare.inc
in NYC since 2009




                       2
Germany and me.




                  3
From Lithium session at Tek X Chicago




                                        4
Agenda


   What is Lithium
   Core functionality
   Recap and announcement




Copyright © YusukeAndo. 2010 - . All rights reserved.   5
What is Lithium?
The origin of Lithium




Copyright © YusukeAndo. 2010 - . All rights reserved.   6
Lithium




     Framework for PHP5.3 or higher
     Light weight, Flexibility
     Document Database as Primary citizen
     Was called as Cake3


Copyright © YusukeAndo. 2010 - . All rights reserved.   7
Gwoo & Nate !




Copyright © YusukeAndo. 2010 - . All rights reserved.   8
Little bit detail

12 developers in project
Current version is 0.9.5 Almost There
CakePHP like code
Able to integrate outside Libraries.
Including Unit Test, Console, Document
Refined View and Model layer.



                                         9
PHP5,3

Namespace
Finally language orgnizes naming rule.
Late Static Binding (LSB)
Allow full extending static class.
Clousure
Promote Aspect Oriented Programming.


  This is time to evolve our self.

                                         10
Core value




             PHP5.3

拡張性(flexibility)
                      11
Core functionality
雰囲気を体験




Copyright © YusukeAndo. 2010 - . All rights reserved.   12
Install

PHP5.3 Also XAMPP
MongoDB is recommended, MySQL is beta.
Just extract archive.
 http://rad-dev.org/lithium/versions
Database setting
 app/config/connections.php


          Simple install steps
                                         13
app/config/connections.php
                                                         namespace
use ¥lithium¥data¥Connections;

Connections::add('default', array(
   'type' => 'MongoDb',
   'host' => 'localhost',
   'database' => 'labo02'
));




 Copyright © YusukeAndo. 2010 - . All rights reserved.               14
Homepage




Copyright © YusukeAndo. 2010 - . All rights reserved.   15
Blog Tutorial

Controller calls PostModel
Writing template with pure php.
If you use MySQL, need to create schema first.
Namespace Namespace Namespace
Smaller code than any other Framework.




                                                 16
app/models/Post.php


<?php                                                       namespace
namespace app¥models;

class Post extends ¥lithium¥data¥Model {

}




    Copyright © YusukeAndo. 2010 - . All rights reserved.               17
app/controllers/PostsController.php


<?php
namespace app¥controllers; Importing model
                           and parent class
use app¥models¥Post;

class PostsController extends ¥lithium¥action¥Controller {

    public function index(){
       $posts = Post::all();                                Return vars to
       return compact('posts');                               template
    }
}


    Copyright © YusukeAndo. 2010 - . All rights reserved.                    18
app/views/posts/index.html.php


<?php foreach($posts as $post): ?>
<article>
<h1><?=$post->title ?></h1>
<p><?=$post->body ?></p>
</article>              Auto escaping
<?php endforeach; ?>




  Copyright © YusukeAndo. 2010 - . All rights reserved.   19
result




Copyright © YusukeAndo. 2010 - . All rights reserved.   20
Where is flexibility ?

Isolatated core classes
   You can replace any class inside flow.
Libraries class is able to load any classes
   Specify structure by closure
Filter system
   No more callback
   Less sub class

                                              21
13 Packages of Lithium

        action           security
        analysys         storage
        console          template
        core             test
        data             tests
        g11n             util
        net

                                    22
Typical class tree

                     Provides common structure for
    Object           each classes.


                     For Static class.
  StaticObject       (including any model classes)


                     Provides configuable structure
   Adaptable


                                                      23
Unified constructor

  Object class provides common constructor

function   __construct(array   $config   =   array())
function   __construct(array   $config   =   array())
function   __construct(array   $config   =   array())
function   __construct(array   $config   =   array())
function   __construct(array   $config   =   array())
function   __construct(array   $config   =   array())
function   __construct(array   $config   =   array())

                                                        24
Adapter provides portability


 Connections   Logger      Catalog   Cache


                Auth       Session


                   Adaptable



                YourAdapter

                                             25
Ready to hack




 You can use any class you
like, even your class or any
      other component


                               26
Case Studies

Doctrine
 http://marianoiglesias.com.ar/li3-lithium/building-a-
blog-with-lithium-and-doctrine/

Twig
 http://rad-dev.org/li3_twig/source
Zend
http://rad-dev.org/lithium/wiki/guides/using/zend


            http://rad-dev.org/projects
                http://lab.lithify.me/

                                                         27
Recap

Lithium is lightest and most flexible.
Using much PHP5.3
   LSB
   NameSpace
   Closure
Community is still growing up.
   Documents and plugin will come soon.

                                          28
特報
     29
【講演】 The Origin of Lithium




 軽量・柔軟な次世代フレームワークLithiumの思想
  やコアフィーチャーを開発者が解説

                              30
それが




      PHP Matsuri



                    31
開催概要


日程
2010/10/02 (Sat) – 2010/10/03 (Sun)
会場
晴海グランドホテル
募集人数
100名 (スタッフ除く)
参加費用
2万円前後(食事・軽食・懇親会込み)


                                      32
タイムスケジュール
Time      October 2 (Sat)   Time     October 3 (Sun)

9:00 -    受付                8:00 –   朝食
10:00                       9:00
10:00 –   基調講演・ゲストセ         10:00 – 開発タイム
12:00     ッション              12:00
12:00 –   昼食・開発開始           12:00 – 昼食・デモ応募締切
13:00                       13:00
13:00 –   ワークショップ・セッ        13:00 - デモ発表
18:00     ション               16:00
18:00 –   夕食                16:30 – 表彰・クロージング
20:00                       17:00
20:00-    お楽しみ
22:00
終日        開発タイム

                                                       33
開発コンテスト・ハッカソン


 未発表作品・機能のコンテストを開催
  PHPに関連している作品(サービス、ツール、ドキュメントなど)

  チームでの応募も可

 開発タイム終了後にデモを実施
  各自持ち時間3分でデモ発表

  審査員によって各賞を選出

 作業スペースは終夜利用可
  まとまった開発時間を確保

                                    34
オールナイト開催


 初日朝9時から開始し、翌日17時に終了
 豪華ゲストによるセッション、ワークショップ
 開発用スペースでは各自開発や質問が可能
 2日目に作品のコンテストを開催


オールナイトでセッション、開発、交流


                         35
質疑応答




   ご静聴ありがとうございました。




  Follow @phpmatsuri
                       36

20100730 phpstudy

  • 1.
    Lithium labo #2 SuperRad Framework 2010/07/30 php-study tokkyo yandod 1
  • 2.
    Who am I nameYusuke Ando a,k,a, yando Talking & Writing in JP PHP community Rakuten.inc Linkshare.inc in NYC since 2009 2
  • 3.
  • 4.
    From Lithium sessionat Tek X Chicago 4
  • 5.
    Agenda What is Lithium Core functionality Recap and announcement Copyright © YusukeAndo. 2010 - . All rights reserved. 5
  • 6.
    What is Lithium? Theorigin of Lithium Copyright © YusukeAndo. 2010 - . All rights reserved. 6
  • 7.
    Lithium Framework for PHP5.3 or higher Light weight, Flexibility Document Database as Primary citizen Was called as Cake3 Copyright © YusukeAndo. 2010 - . All rights reserved. 7
  • 8.
    Gwoo & Nate! Copyright © YusukeAndo. 2010 - . All rights reserved. 8
  • 9.
    Little bit detail 12developers in project Current version is 0.9.5 Almost There CakePHP like code Able to integrate outside Libraries. Including Unit Test, Console, Document Refined View and Model layer. 9
  • 10.
    PHP5,3 Namespace Finally language orgnizesnaming rule. Late Static Binding (LSB) Allow full extending static class. Clousure Promote Aspect Oriented Programming. This is time to evolve our self. 10
  • 11.
    Core value PHP5.3 拡張性(flexibility) 11
  • 12.
    Core functionality 雰囲気を体験 Copyright ©YusukeAndo. 2010 - . All rights reserved. 12
  • 13.
    Install PHP5.3 Also XAMPP MongoDBis recommended, MySQL is beta. Just extract archive. http://rad-dev.org/lithium/versions Database setting app/config/connections.php Simple install steps 13
  • 14.
    app/config/connections.php namespace use ¥lithium¥data¥Connections; Connections::add('default', array( 'type' => 'MongoDb', 'host' => 'localhost', 'database' => 'labo02' )); Copyright © YusukeAndo. 2010 - . All rights reserved. 14
  • 15.
    Homepage Copyright © YusukeAndo.2010 - . All rights reserved. 15
  • 16.
    Blog Tutorial Controller callsPostModel Writing template with pure php. If you use MySQL, need to create schema first. Namespace Namespace Namespace Smaller code than any other Framework. 16
  • 17.
    app/models/Post.php <?php namespace namespace app¥models; class Post extends ¥lithium¥data¥Model { } Copyright © YusukeAndo. 2010 - . All rights reserved. 17
  • 18.
    app/controllers/PostsController.php <?php namespace app¥controllers; Importingmodel and parent class use app¥models¥Post; class PostsController extends ¥lithium¥action¥Controller { public function index(){ $posts = Post::all(); Return vars to return compact('posts'); template } } Copyright © YusukeAndo. 2010 - . All rights reserved. 18
  • 19.
    app/views/posts/index.html.php <?php foreach($posts as$post): ?> <article> <h1><?=$post->title ?></h1> <p><?=$post->body ?></p> </article> Auto escaping <?php endforeach; ?> Copyright © YusukeAndo. 2010 - . All rights reserved. 19
  • 20.
    result Copyright © YusukeAndo.2010 - . All rights reserved. 20
  • 21.
    Where is flexibility? Isolatated core classes You can replace any class inside flow. Libraries class is able to load any classes Specify structure by closure Filter system No more callback Less sub class 21
  • 22.
    13 Packages ofLithium action security analysys storage console template core test data tests g11n util net 22
  • 23.
    Typical class tree Provides common structure for Object each classes. For Static class. StaticObject (including any model classes) Provides configuable structure Adaptable 23
  • 24.
    Unified constructor Object class provides common constructor function __construct(array $config = array()) function __construct(array $config = array()) function __construct(array $config = array()) function __construct(array $config = array()) function __construct(array $config = array()) function __construct(array $config = array()) function __construct(array $config = array()) 24
  • 25.
    Adapter provides portability Connections Logger Catalog Cache Auth Session Adaptable YourAdapter 25
  • 26.
    Ready to hack You can use any class you like, even your class or any other component 26
  • 27.
    Case Studies Doctrine http://marianoiglesias.com.ar/li3-lithium/building-a- blog-with-lithium-and-doctrine/ Twig http://rad-dev.org/li3_twig/source Zend http://rad-dev.org/lithium/wiki/guides/using/zend http://rad-dev.org/projects http://lab.lithify.me/ 27
  • 28.
    Recap Lithium is lightestand most flexible. Using much PHP5.3 LSB NameSpace Closure Community is still growing up. Documents and plugin will come soon. 28
  • 29.
  • 30.
    【講演】 The Originof Lithium 軽量・柔軟な次世代フレームワークLithiumの思想 やコアフィーチャーを開発者が解説 30
  • 31.
    それが PHP Matsuri 31
  • 32.
    開催概要 日程 2010/10/02 (Sat) –2010/10/03 (Sun) 会場 晴海グランドホテル 募集人数 100名 (スタッフ除く) 参加費用 2万円前後(食事・軽食・懇親会込み) 32
  • 33.
    タイムスケジュール Time October 2 (Sat) Time October 3 (Sun) 9:00 - 受付 8:00 – 朝食 10:00 9:00 10:00 – 基調講演・ゲストセ 10:00 – 開発タイム 12:00 ッション 12:00 12:00 – 昼食・開発開始 12:00 – 昼食・デモ応募締切 13:00 13:00 13:00 – ワークショップ・セッ 13:00 - デモ発表 18:00 ション 16:00 18:00 – 夕食 16:30 – 表彰・クロージング 20:00 17:00 20:00- お楽しみ 22:00 終日 開発タイム 33
  • 34.
    開発コンテスト・ハッカソン 未発表作品・機能のコンテストを開催 PHPに関連している作品(サービス、ツール、ドキュメントなど) チームでの応募も可 開発タイム終了後にデモを実施 各自持ち時間3分でデモ発表 審査員によって各賞を選出 作業スペースは終夜利用可 まとまった開発時間を確保 34
  • 35.
    オールナイト開催 初日朝9時から開始し、翌日17時に終了 豪華ゲストによるセッション、ワークショップ 開発用スペースでは各自開発や質問が可能 2日目に作品のコンテストを開催 オールナイトでセッション、開発、交流 35
  • 36.
    質疑応答 ご静聴ありがとうございました。 Follow @phpmatsuri 36