Upgrade to Pro — share decks privately, control downloads, hide ads and more …

OSDC.TW 2012 - The ecosystems of PHP and Perl

Yo-An Lin
April 15, 2012
1.6k

OSDC.TW 2012 - The ecosystems of PHP and Perl

Yo-An Lin

April 15, 2012
Tweet

Transcript

  1. The Ecosystems of
    Perl & PHP
    林佑安 (c9s)
    Saturday, April 14, 12

    View Slide

  2. Speaker
    • 林佑安 [email protected], [email protected]
    • Web Developer
    • CPAN author for ~30 distributions.
    • 187 repos/projects on GitHub.
    • Perl programming since 2008.
    • PHP programming since 2011.
    Saturday, April 14, 12

    View Slide

  3. 我本來是個 XXX Developer
    Saturday, April 14, 12

    View Slide

  4. 直到我膝蓋中了⼀一箭...
    Saturday, April 14, 12

    View Slide

  5. 但是
    Saturday, April 14, 12

    View Slide

  6. 今天不是要來打臉的
    Saturday, April 14, 12

    View Slide

  7. Let’s take a look at PHP from Perl.
    從 Perl 的角度來看 PHP
    Saturday, April 14, 12

    View Slide

  8. Language
    Saturday, April 14, 12

    View Slide

  9. PHP
    Saturday, April 14, 12

    View Slide

  10. Rasmus Lerdorf
    於 1995 年發明 PHP
    Danish Programmer
    Saturday, April 14, 12

    View Slide

  11. PHP3
    Zeev Suraski Andi Gutmans
    Zend Technologies
    Saturday, April 14, 12

    View Slide

  12. A general-purpose
    server-side scripting language
    伺服端的腳本語言
    Saturday, April 14, 12

    View Slide

  13. A general-purpose
    server-side scripting language
    伺服端的腳本樣板語言
    Saturday, April 14, 12

    View Slide

  14. 動態產生網頁內容
    Saturday, April 14, 12

    View Slide

  15. PHP
    • 從 C 語言 CGI 函式庫發展
    • 以早期 Perl 的部分語法為雛形
    • 2002 年 PHP 4.3.0 新增 CLI SAPI
    • 2004 年 PHP 5.0.0 新增類 Java 的物件模

    • 2012 年 PHP 5.4 引進 Trait, 內建 Http
    Server, 大量改善 Zend Engine 效能
    Saturday, April 14, 12

    View Slide

  16. Perl
    Saturday, April 14, 12

    View Slide

  17. Larry Wall
    程式員, 系統管理員,
    語言學家, 作家
    1987 年發明 Perl
    Saturday, April 14, 12

    View Slide

  18. There's More Than One Way To Do It.
    不只⼀一種方法來做⼀一件事情
    Saturday, April 14, 12

    View Slide

  19. 為了「...」而設計的的 Perl
    “When Larry designed the first Perl, he was a
    sysadmin, Perl was designed for sysadmins.
    When Perl5 was created, Larry was a programmer.
    Perl5 is designed for programming.
    It is a programming language.
    Larry is now a language designer, Perl6 is a language
    for language design.” - Jesse Vincent
    from gugod http://gugod.org/2011/11/perl-for-dot-dot-dot/
    Saturday, April 14, 12

    View Slide

  20. Perl: 以簡馭繁的中心思想
    $list  =  array_map(function($item)  {  
                                   return  $item  .  'bar';
                           },  array_filter(  $list,  function($item)  {  
                                   return  preg_match('#^foo#',$item);
                           });
    Saturday, April 14, 12

    View Slide

  21. Perl: 以簡馭繁的中心思想
    $list  =  array_map(function($item)  {  
                                   return  $item  .  'bar';
                           },  array_filter(  $list,  function($item)  {  
                                   return  preg_match('#^foo#',$item);
                           });
    #  perl
    @list  =  map  {  $_  .  'bar'  }  grep  /^foo/,  @list;
    Saturday, April 14, 12

    View Slide

  22. Perl
    • 從 Unix scripting language 出發
    • 借取了 C, sed, awk, shell 等特性
    • 1990 年時大量 CGI 程式使用 Perl 寫作
    • 1994 年 Perl5 加入 OOP
    • 5.8.0 版時加入了 Unicode 支援
    • 2006 年第⼀一版 Moose 模組 (後現代物件系統) - 可改
    善 Perl 的物件導向功能,包含 Trait, Lazy Attributes 等
    功能
    • 2009 年 Plack 模組的出現使得 Perl 於 Web 開發上效
    能、便利性更是大大提昇。
    Saturday, April 14, 12

    View Slide

  23. 小結
    • PHP 在語言設計上,除了 server-side scripting
    language 外並無明顯的中心思想
    • Perl 以命令列發展至 Web,而 PHP 是後來才加
    入了命令列支援。
    • 類別自動載入機制,是在 PHP 5.x 版後才加
    入,因此多數 PHP 模組載入方式、路徑格式差
    異相當大,也使得各系統間元件相當難重新使
    用 (reuse)
    Saturday, April 14, 12

    View Slide

  24. Package System
    Saturday, April 14, 12

    View Slide

  25. PHP
    Saturday, April 14, 12

    View Slide

  26. PEAR
    http://pear.php.net
    Saturday, April 14, 12

    View Slide

  27. PECL
    http://pecl.php.net
    Saturday, April 14, 12

    View Slide

  28. PHP ecosystem
    • since 1999-11-21
    Saturday, April 14, 12

    View Slide

  29. PHP ecosystem
    • since 1999-11-21
    • 586 packages on pear.php.net
    Saturday, April 14, 12

    View Slide

  30. PHP ecosystem
    • since 1999-11-21
    • 586 packages on pear.php.net
    • 280 extensions on pecl.php.net
    Saturday, April 14, 12

    View Slide

  31. PHP ecosystem
    • since 1999-11-21
    • 586 packages on pear.php.net
    • 280 extensions on pecl.php.net
    • 19 packages on pear2.php.net
    Saturday, April 14, 12

    View Slide

  32. PHP ecosystem
    • since 1999-11-21
    • 586 packages on pear.php.net
    • 280 extensions on pecl.php.net
    • 19 packages on pear2.php.net
    • 840 packages on packagist.org
    Saturday, April 14, 12

    View Slide

  33. PHP ecosystem
    • since 1999-11-21
    • 586 packages on pear.php.net
    • 280 extensions on pecl.php.net
    • 19 packages on pear2.php.net
    • 840 packages on packagist.org
    • no package tester.
    Saturday, April 14, 12

    View Slide

  34. PHP ecosystem
    • since 1999-11-21
    • 586 packages on pear.php.net
    • 280 extensions on pecl.php.net
    • 19 packages on pear2.php.net
    • 840 packages on packagist.org
    • no package tester & reports
    • 2 mirror sites (us, de)
    Saturday, April 14, 12

    View Slide

  35. PHP ecosystem
    • Use `pear` and `pyrus.phar` to install PEAR
    packages (system-wide).
    • Pirum, PEAR channel builder.
    • MiniPear, PEAR channel mirror tool.
    Saturday, April 14, 12

    View Slide

  36. Perl
    Saturday, April 14, 12

    View Slide

  37. CPAN
    http://search.cpan.org
    Saturday, April 14, 12

    View Slide

  38. CPAN Tester: test matrix
    http://cpantesters.org
    Saturday, April 14, 12

    View Slide

  39. MetaCPAN
    https://metacpan.org/
    Saturday, April 14, 12

    View Slide

  40. CPAN Dependencies
    Saturday, April 14, 12

    View Slide

  41. CPAN
    • Since October 1995
    Saturday, April 14, 12

    View Slide

  42. CPAN
    • Since October 1995
    • 77800 Uploads
    Saturday, April 14, 12

    View Slide

  43. CPAN
    • Since October 1995
    • 77800 Uploads
    • 24637 Distributions
    Saturday, April 14, 12

    View Slide

  44. CPAN
    • Since October 1995
    • 77800 Uploads
    • 24637 Distributions
    • 105724 Modules
    Saturday, April 14, 12

    View Slide

  45. CPAN
    • Since October 1995
    • 77800 Uploads
    • 24637 Distributions
    • 105724 Modules
    • 9627 Authors
    Saturday, April 14, 12

    View Slide

  46. CPAN
    • Since October 1995
    • 77800 Uploads
    • 24637 Distributions
    • 105724 Modules
    • 9627 Authors
    • 245 mirror sites
    Saturday, April 14, 12

    View Slide

  47. CPAN
    • Since October 1995
    • 77800 Uploads
    • 24637 Distributions
    • 105724 Modules
    • 9627 Authors
    • 245 mirror sites
    • Issue Tracker (RT)
    Saturday, April 14, 12

    View Slide

  48. CPAN
    • Since October 1995
    • 77800 Uploads
    • 24637 Distributions
    • 105724 Modules
    • 9627 Authors
    • 245 mirror sites
    • Issue Tracker (RT)
    • CPAN Tester since
    1999
    Saturday, April 14, 12

    View Slide

  49. CPAN
    • Since October 1995
    • 77800 Uploads
    • 24637 Distributions
    • 105724 Modules
    • 9627 Authors
    • 245 mirror sites
    • Issue Tracker (RT)
    • CPAN Tester since
    1999
    • MetaCPAN
    Saturday, April 14, 12

    View Slide

  50. 1000+ distribution
    uploads per month.
    From CPAN Tester statistics
    http://stats.cpantesters.org/trends.html
    Saturday, April 14, 12

    View Slide

  51. 250+ new distribution
    uploads per month
    From CPAN Tester statistics
    http://stats.cpantesters.org/trends.html
    Saturday, April 14, 12

    View Slide

  52. Command-line Tools
    • cpan (Original CPAN shell)
    • cpanp (CPANPLUS)
    • cpanm (CPAN Minus)
    • carton (Bundler)
    • pinto (CPAN package repository tool)
    • CPAN::Mini (CPAN Mirror Tool)
    Saturday, April 14, 12

    View Slide

  53. 對此, PHP 表示...
    Saturday, April 14, 12

    View Slide

  54. Saturday, April 14, 12

    View Slide

  55. 為何有如此巨大差異 ?
    Why such a big difference ?
    Saturday, April 14, 12

    View Slide

  56. 三個問題
    Three problems
    Saturday, April 14, 12

    View Slide

  57. Problem #1
    PEAR 繁瑣的上傳程序
    Saturday, April 14, 12

    View Slide

  58. 如何上傳 CPAN
    package ?
    Saturday, April 14, 12

    View Slide

  59. 上傳 CPAN Package: 3 Steps
    • Register a PAUSE
    account
    http://pause.perl.org/
    Saturday, April 14, 12

    View Slide

  60. 上傳 CPAN Package: 3 Steps
    • Register a PAUSE
    account
    • Confirm your
    email
    http://pause.perl.org/
    Saturday, April 14, 12

    View Slide

  61. 上傳 CPAN Package: 3 Steps
    • Register a PAUSE
    account
    • Confirm your
    email
    • Upload!
    http://pause.perl.org/
    Saturday, April 14, 12

    View Slide

  62. CPAN Shipping tools
    • ShipIt
    • CPAN::Uploader
    Saturday, April 14, 12

    View Slide

  63. CPAN Shipping tools
    • ShipIt
    • CPAN::Uploader
    ⼀一鍵搞定版本釋出
    Saturday, April 14, 12

    View Slide

  64. 那麼如何上傳
    PEAR Package ?
    Saturday, April 14, 12

    View Slide

  65. Upload PEAR package
    • Register a PEAR account
    Saturday, April 14, 12

    View Slide

  66. Upload PEAR package
    • Register a PEAR account
    • Confirm Email
    Saturday, April 14, 12

    View Slide

  67. Upload PEAR package
    • Register a PEAR account
    • Confirm Email
    • Are we done yet ?
    Saturday, April 14, 12

    View Slide

  68. And not yet
    • Join Mailing List
    Saturday, April 14, 12

    View Slide

  69. And not yet
    • Join Mailing List
    • Use PHP_CodeSniffer to
    verify your standard
    coding convention.
    Saturday, April 14, 12

    View Slide

  70. And not yet
    • Join Mailing List
    • Use PHP_CodeSniffer to
    verify your standard
    coding convention.
    • Create a proposal draft
    Saturday, April 14, 12

    View Slide

  71. And not yet
    • Join Mailing List
    • Use PHP_CodeSniffer to
    verify your standard
    coding convention.
    • Create a proposal draft
    • Proposal stage, discuss &
    discuss ...
    Saturday, April 14, 12

    View Slide

  72. And not yet
    • Join Mailing List
    • Use PHP_CodeSniffer to
    verify your standard
    coding convention.
    • Create a proposal draft
    • Proposal stage, discuss &
    discuss ...
    • Waiting for votes
    Saturday, April 14, 12

    View Slide

  73. And not yet
    • Join Mailing List
    • Use PHP_CodeSniffer to
    verify your standard
    coding convention.
    • Create a proposal draft
    • Proposal stage, discuss &
    discuss ...
    • Waiting for votes
    • Proposal finished
    Saturday, April 14, 12

    View Slide

  74. 然後呢?等 ...
    Saturday, April 14, 12

    View Slide

  75. 等你等到海枯石爛~
    Saturday, April 14, 12

    View Slide

  76. You don’t even suffer such
    process on GitHub!
    Saturday, April 14, 12

    View Slide

  77. Problem #2
    各自為政的套件庫
    Saturday, April 14, 12

    View Slide

  78. CPAN
    PHP Packages are not centralized like CPAN
    Saturday, April 14, 12

    View Slide

  79. CPAN
    PHP Packages are not centralized like CPAN
    Saturday, April 14, 12

    View Slide

  80. CPAN
    PHP Packages are not centralized like CPAN
    Saturday, April 14, 12

    View Slide

  81. CPAN
    PHP Packages are not centralized like CPAN
    Saturday, April 14, 12

    View Slide

  82. PEAR
    Most packages and libraries are not on PEAR,
    they have their own channels.
    Saturday, April 14, 12

    View Slide

  83. PHPUnit
    PEAR
    Symfony
    Zend
    Pyrus
    phpmd
    phpspec
    phrozn
    Most packages and libraries are not on PEAR,
    they have their own channels.
    ezComponents
    Drupal Packages
    WordPress
    Composer
    pearfarm
    OpenPEAR
    Saturday, April 14, 12

    View Slide

  84. And no mirrors
    Saturday, April 14, 12

    View Slide

  85. PEAR
    Most packages and libraries are not on PEAR,
    they have their own channels.
    Saturday, April 14, 12

    View Slide

  86. It makes channel list longer and longer
    Saturday, April 14, 12

    View Slide

  87. It makes channel list longer and longer
    Saturday, April 14, 12

    View Slide

  88. 套件難以搜尋
    it’s hard to search packages
    Saturday, April 14, 12

    View Slide

  89. PEAR package hosting
    pearfarm.org
    openpear.org
    Saturday, April 14, 12

    View Slide

  90. Problem #3
    The Hard Package
    Meta file
    Saturday, April 14, 12

    View Slide

  91. use inc::Module::Install;
    name 'Plack';
    all_from 'lib/Plack.pm';
    readme_from 'lib/Plack.pm';
    requires 'LWP::UserAgent', 5.814;
    requires 'HTTP::Message', 5.814;
    requires 'URI', 1.36;
    tests 't/*.t t/*/*.t';
    author_tests 'xt';
    install_share 'share';
    install_script 'scripts/plackup';
    auto_install;
    auto_set_repository;
    resources
    homepage => "http://plackperl.org",
    bugtracker => "https://github.com/
    miyagawa/plack/issues";
    WriteAll;
    This is how we do in Perl
    Saturday, April 14, 12

    View Slide

  92. This is how we do in Perl
    $ perl Makefile.PL
    Saturday, April 14, 12

    View Slide

  93. • Simple
    Makefile.PL
    Saturday, April 14, 12

    View Slide

  94. • Simple
    • Clean
    Makefile.PL
    Saturday, April 14, 12

    View Slide

  95. • Simple
    • Clean
    • Flexible
    Makefile.PL
    Saturday, April 14, 12

    View Slide

  96. • Simple
    • Clean
    • Flexible
    • Pure Perl
    Makefile.PL
    Saturday, April 14, 12

    View Slide

  97. • Simple
    • Clean
    • Flexible
    • Pure Perl
    Makefile.PL
    Saturday, April 14, 12

    View Slide

  98. How to build a PEAR
    package ?
    Saturday, April 14, 12

    View Slide

  99. package.xml
    Saturday, April 14, 12

    View Slide

  100. 規格書第⼀一
    看完再來 Build package 吧!
    Saturday, April 14, 12

    View Slide

  101. package.xml


    gearman
    pecl.php.net
    PHP wrapper to libgearman
    This extension uses libgearman library to provide API for communicating
    with gearmand, and writing clients and workers.

    James M. Luedke
    jluedke
    [email protected]
    no


    Herman J. Radtke III
    hradtke
    [email protected]
    yes

    2011-12-05
    16:41:40

    1.0.1
    1.0.1


    stable
    stable

    Saturday, April 14, 12

    View Slide

  102. package.xml
    PHP

    - Fixed PECL Bug #60438 (wrong version number in php_gearman.h)
























    Saturday, April 14, 12

    View Slide

  103. package.xml



    5.1.0
    6.0.0
    6.0.0


    1.4.0b1



    gearman




    stable
    stable


    1.0.1
    1.0.1

    2011-12-05

    - Fixed PECL Bug #60438 (wrong version number in php_gearman.h)


    .... cut ....

    Saturday, April 14, 12

    View Slide

  104. 你暈了嗎
    Saturday, April 14, 12

    View Slide

  105. 這應該是要透過工具產生才
    對吧 ?
    Saturday, April 14, 12

    View Slide

  106. Build tool
    • PEAR_PackageFileManager_Cli
    • Pyrus make, generate-pear2 command
    Saturday, April 14, 12

    View Slide

  107. 不過...
    Saturday, April 14, 12

    View Slide

  108. Unfortunately
    • 既有的 package file builder 幾乎都無法正
    常運作 (不斷丟出 Exceptions)
    Saturday, April 14, 12

    View Slide

  109. Unfortunately
    • 既有的 package file builder 幾乎都無法正
    常運作 (不斷丟出 Exceptions)
    • 無清楚的文件
    Saturday, April 14, 12

    View Slide

  110. Unfortunately
    • 既有的 package file builder 幾乎都無法正
    常運作 (不斷丟出 Exceptions)
    • 無清楚的文件
    • 操作繁瑣,必須⼀一行行依照詢問輸入
    Saturday, April 14, 12

    View Slide

  111. Unfortunately
    • 既有的 package file builder 幾乎都無法正
    常運作 (不斷丟出 Exceptions)
    • 無清楚的文件
    • 操作繁瑣,必須⼀一行行依照詢問輸入
    • XML Tag 順序不對,就無法建置
    Saturday, April 14, 12

    View Slide

  112. Unfortunately
    • 既有的 package file builder 幾乎都無法正
    常運作 (不斷丟出 Exceptions)
    • 無清楚的文件
    • 操作繁瑣,必須⼀一行行依照詢問輸入
    • XML Tag 順序不對,就無法建置
    • 雖然可以用 composer ,但卻是另外的生
    態系統。
    Saturday, April 14, 12

    View Slide

  113. Saturday, April 14, 12

    View Slide

  114. Saturday, April 14, 12

    View Slide

  115. 小結
    Saturday, April 14, 12

    View Slide

  116. CPAN
    • 自由且開放: 任何人都可以快速發佈自己
    的作品
    • 多樣性: ⼀一種目的多種原型、實作,開發
    者能有更多的選擇
    • 完整的測試系統: 不會隨便亂炸掉
    • 以簡馭繁
    Saturday, April 14, 12

    View Slide

  117. PEAR
    • 封閉: 上傳套件必須審核審核再審核
    • 小團體: PEAR Team < 20 人
    • 無系統化測試
    • 不友善的 Issue Tracker
    • 設計複雜、繁瑣
    Saturday, April 14, 12

    View Slide

  118. 如果是如此,該如何改善呢 ?
    If so, how to improve the PHP package
    system ?
    Saturday, April 14, 12

    View Slide

  119. The Recent tools
    • Pyrus: pear2.php.net, is not opened yet. 但工具本
    身仍在 Alpha stage.
    • bundle install = Hack
    • 仍是使用 package.xml
    Saturday, April 14, 12

    View Slide

  120. The Recent tools
    • Pyrus: pear2.php.net, is not opened yet. 但工具本
    身仍在 Alpha stage.
    • bundle install = Hack
    • 仍是使用 package.xml
    • Composer project by @baderman,@Seldaek
    inspired from npmjs & opensuse.
    • JSON meta file
    Saturday, April 14, 12

    View Slide

  121. • 需要⼀一個更簡潔的套件定義檔案
    Saturday, April 14, 12

    View Slide

  122. • 需要⼀一個更簡潔的套件定義檔案
    • 能夠完整產生 package.xml 達到向後相容
    PEAR 套件以及 PEAR Channel
    Saturday, April 14, 12

    View Slide

  123. • 需要⼀一個更簡潔的套件定義檔案
    • 能夠完整產生 package.xml 達到向後相容
    PEAR 套件以及 PEAR Channel
    • 需能管理套件相依性,如 Bundler
    Saturday, April 14, 12

    View Slide

  124. We Can Do Better
    Saturday, April 14, 12

    View Slide

  125. Onion
    The PEAR packager
    https://github.com/c9s/Onion
    Saturday, April 14, 12

    View Slide

  126. The package.ini File
    [package]
    name = PackageName
    desc = description
    version = 1.2.0
    author = “c9s ”
    channel = pear.host.com
    Saturday, April 14, 12

    View Slide

  127. The package.ini File
    [package]
    name = PackageName
    desc = description
    version = 1.2.0
    author = “c9s ”
    channel = pear.host.com
    5+ lines to create a package.
    Saturday, April 14, 12

    View Slide

  128. How to use it?
    • Put your class files in `src/`
    • Tests in `tests/`
    • documentation in `doc/`
    Saturday, April 14, 12

    View Slide

  129. 妥善配置 Class path
    Saturday, April 14, 12

    View Slide

  130. PEAR Class name rule
    • Twig_Loader_Filesystem => src/Twig/Loader/
    Filesystem.php
    • Foo_Class_Bar => src/Foo/Class/Bar.php
    • Foo => src/Foo.php
    Saturday, April 14, 12

    View Slide

  131. PHP Standard Working Group
    Saturday, April 14, 12

    View Slide

  132. PSR-0 classname rule
    • Class\SubClass => src/Class/SubClass.php
    • Foo => src/Foo.php
    • Foo\Bar\Zoo => src/Foo/Bar/Zoo.php
    Saturday, April 14, 12

    View Slide

  133. PSR-0 classname rule
    • Class\SubClass => src/Class/SubClass.php
    • Foo => src/Foo.php
    • Foo\Bar\Zoo => src/Foo/Bar/Zoo.php
    • Foo::Bar => lib/Foo/Bar.pm
    • Foo => lib/Foo.pm
    • Foo::Bar::Zoo => lib/Foo/Bar/Zoo.pm
    Perl:
    Saturday, April 14, 12

    View Slide

  134. Build PEAR package
    $  curl  -­‐s  http://install.onionphp.org/  |  bash
    $  vi  package.ini
    $  onion  build            #  package.xml  is  out
    $  pyrus  package        #  build  *.tgz
    Saturday, April 14, 12

    View Slide

  135. Saturday, April 14, 12

    View Slide

  136. Bundle packages
    [require]
    php = 5.3
    pearinstaller = 1.4.1
    pear.phpspec.net/PHPSpec = 1.2.2beta
    pear.symfony-project.com/YAML = “> 1.2”
    pear.twig-project.org/Twig = “< 0.3”
    pear.phpunit.de/PHPUnit = 0.0.1
    PKG = http://host/to/package.tgz
    Saturday, April 14, 12

    View Slide

  137. Bundle packages
    $ onion bundle
    # install packages into vendor/ dir.
    Saturday, April 14, 12

    View Slide

  138. Bundle packages
    $  tree  -­‐d  vendor  
    vendor
    !""  pear
           #""  CLIFramework
           $      !""  Command
           #""  CacheKit
           #""  GetOptionKit
           #""  PEARX
           #""  SerializerKit
           #""  SymfonyComponents
           $      !""  YAML
           !""  Universal
                   #""  ClassLoader
                   #""  Container
                   #""  Event
                   #""  FileSystem
    Saturday, April 14, 12

    View Slide

  139. 建置 Autoload Script
    Saturday, April 14, 12

    View Slide

  140. SPL ClassLoaders
    • Symfony\ClassLoader\UniversalClassLoader
    • Universal\ClassLoader\SplClassLoader
    • Universal\ClassLoader\BasePathClassLoader
    Saturday, April 14, 12

    View Slide

  141. SPL ClassLoader
    # autoload.php
    require 'Universal/ClassLoader/SplClassLoader.php';
    $classLoader = new \Universal\ClassLoader\SplClassLoader(array(
    'Onion' => 'src',
    'CurlKit' => 'src',
    'PEARX' => 'vendor/pear',
    'CacheKit' => 'vendor/pear',
    'CLIFramework' => 'vendor/pear',
    'GetOptionKit' => 'vendor/pear',
    ));
    $classLoader->useIncludePath(true);
    $classLoader->register();
    Saturday, April 14, 12

    View Slide

  142. SPL ClassLoader
    # autoload.php
    require 'Universal/ClassLoader/BasePathClassLoader.php';
    $loader = new \Universal\ClassLoader
    \BasePathClassLoader( array(
    'src',
    'vendor/pear'
    ));
    $loader->useIncludePath(true);
    $loader->register();
    Saturday, April 14, 12

    View Slide

  143. 打包 㱺 Standalone executable
    Saturday, April 14, 12

    View Slide

  144. To build a standalone
    binary
    #!/bin/bash
    onion compile \
    --lib src \
    --lib vendor/pear \
    --classloader \
    --bootstrap scripts/onion.embed \
    --executable \
    --output onion.phar
    chmod +x onion.phar
    Saturday, April 14, 12

    View Slide

  145. To build a standalone
    binary
    $ ./package.phar
    Saturday, April 14, 12

    View Slide

  146. 打包 㱺 Standalone library
    Saturday, April 14, 12

    View Slide

  147. To build a standalone
    binary
    require 'bundle.phar';
    ?>
    Saturday, April 14, 12

    View Slide

  148. 搭配 Pirum PEAR Channel Builder
    即可快速佈署、散佈公用/私用套件
    Pirum PEAR
    Channel
    Client
    Client
    Client
    Saturday, April 14, 12

    View Slide

  149. 副產品
    • PHPBrew - (perlbrew,rvm-like tool)
    • CLIFramework - Command-Line app
    framework.
    • GetOptionKit - getopt parser.
    • PEARX - PEAR channel client library.
    • CurlKit - curl download tool.
    • MiniPear - PEAR channel mirror tool
    Saturday, April 14, 12

    View Slide

  150. Future work
    • Support VCS
    repository (github,
    git, hg, svn)
    • Lock file
    • Better channel
    protocol
    • Autoloader
    generator
    • Authentication
    support
    • Support SSH
    • Fork welcome
    Saturday, April 14, 12

    View Slide

  151. Conclusion
    • PHP 生態系統雖先天不足,但 PHP 開發者及市場
    仍相當大。 最近兩年 PSR (PHP Standard Group -
    Framework Developers) 逐漸在發展共通的規範,
    達到元件 reuse 的目的。
    • Composer 雖是獨立的生態系統,且目前主要用
    於 Symfony,但可期待未來的發展。
    • 期待 PHP 生態系統能有更好的改善
    Saturday, April 14, 12

    View Slide

  152. Conclusion
    • PHP 生態系統雖先天不足,但 PHP 開發者及市場
    仍相當大。 最近兩年 PSR (PHP Standard Group -
    Framework Developers) 逐漸在發展共通的規範,
    達到元件 reuse 的目的。
    • Composer 雖是獨立的生態系統,且目前主要用
    於 Symfony,但可期待未來的發展。
    • 期待 PHP 生態系統能有更好的改善 ~CoffeePHP ?
    Saturday, April 14, 12

    View Slide

  153. Q & A
    Thanks!
    [email protected]
    Twitter: http://twitter.com/c9s
    GitHub: http://github.com/c9s
    Saturday, April 14, 12

    View Slide