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

OSDC.TW 2012 - The ecosystems of PHP and Perl

7490b4e3e9cb85a1f7dc0c8ea01a86e5?s=47 Yo-An Lin
April 15, 2012
1.5k

OSDC.TW 2012 - The ecosystems of PHP and Perl

7490b4e3e9cb85a1f7dc0c8ea01a86e5?s=128

Yo-An Lin

April 15, 2012
Tweet

Transcript

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

    14, 12
  2. Speaker • 林佑安 c9s@twitter, c9s@github • Web Developer • CPAN

    author for ~30 distributions. • 187 repos/projects on GitHub. • Perl programming since 2008. • PHP programming since 2011. Saturday, April 14, 12
  3. 我本來是個 XXX Developer Saturday, April 14, 12

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

  5. 但是 Saturday, April 14, 12

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

  7. Let’s take a look at PHP from Perl. 從 Perl

    的角度來看 PHP Saturday, April 14, 12
  8. Language Saturday, April 14, 12

  9. PHP Saturday, April 14, 12

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

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

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

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

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

  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
  16. Perl Saturday, April 14, 12

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

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

    April 14, 12
  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
  20. Perl: 以簡馭繁的中心思想 <?php $list  =  array_map(function($item)  {      

                               return  $item  .  'bar';                        },  array_filter(  $list,  function($item)  {                                  return  preg_match('#^foo#',$item);                        }); Saturday, April 14, 12
  21. Perl: 以簡馭繁的中心思想 <?php $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
  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
  23. 小結 • PHP 在語言設計上,除了 server-side scripting language 外並無明顯的中心思想 • Perl

    以命令列發展至 Web,而 PHP 是後來才加 入了命令列支援。 • 類別自動載入機制,是在 PHP 5.x 版後才加 入,因此多數 PHP 模組載入方式、路徑格式差 異相當大,也使得各系統間元件相當難重新使 用 (reuse) Saturday, April 14, 12
  24. Package System Saturday, April 14, 12

  25. PHP Saturday, April 14, 12

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

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

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

  29. PHP ecosystem • since 1999-11-21 • 586 packages on pear.php.net

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

    • 280 extensions on pecl.php.net Saturday, April 14, 12
  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
  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
  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
  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
  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
  36. Perl Saturday, April 14, 12

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

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

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

  40. CPAN Dependencies Saturday, April 14, 12

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

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

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

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

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

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

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

    Distributions • 105724 Modules • 9627 Authors • 245 mirror sites • Issue Tracker (RT) Saturday, April 14, 12
  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
  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
  50. 1000+ distribution uploads per month. From CPAN Tester statistics http://stats.cpantesters.org/trends.html

    Saturday, April 14, 12
  51. 250+ new distribution uploads per month From CPAN Tester statistics

    http://stats.cpantesters.org/trends.html Saturday, April 14, 12
  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
  53. 對此, PHP 表示... Saturday, April 14, 12

  54. Saturday, April 14, 12

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

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

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

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

  59. 上傳 CPAN Package: 3 Steps • Register a PAUSE account

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

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

    • Confirm your email • Upload! http://pause.perl.org/ Saturday, April 14, 12
  62. CPAN Shipping tools • ShipIt • CPAN::Uploader Saturday, April 14,

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

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

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

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

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

    Email • Are we done yet ? Saturday, April 14, 12
  68. And not yet • Join Mailing List Saturday, April 14,

    12
  69. And not yet • Join Mailing List • Use PHP_CodeSniffer

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

    to verify your standard coding convention. • Create a proposal draft Saturday, April 14, 12
  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
  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
  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
  74. 然後呢?等 ... Saturday, April 14, 12

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

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

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

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

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

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

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

    14, 12
  82. PEAR Most packages and libraries are not on PEAR, they

    have their own channels. Saturday, April 14, 12
  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
  84. And no mirrors Saturday, April 14, 12

  85. PEAR Most packages and libraries are not on PEAR, they

    have their own channels. Saturday, April 14, 12
  86. It makes channel list longer and longer Saturday, April 14,

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

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

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

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

    12
  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
  92. This is how we do in Perl $ perl Makefile.PL

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

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

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

    12
  96. • Simple • Clean • Flexible • Pure Perl Makefile.PL

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

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

    12
  99. package.xml Saturday, April 14, 12

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

  101. package.xml <?xml version="1.0" encoding="ISO-8859-1"?> <package packagerversion="1.9.4" version="2.0" xmlns="http://pear.php.net/dtd/ package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"

    xmlns:xsi="http:// www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/ tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> <name>gearman</name> <channel>pecl.php.net</channel> <summary>PHP wrapper to libgearman</summary> <description>This extension uses libgearman library to provide API for communicating with gearmand, and writing clients and workers.</description> <lead> <name>James M. Luedke</name> <user>jluedke</user> <email>contact@jamesluedke.com</email> <active>no</active> </lead> <lead> <name>Herman J. Radtke III</name> <user>hradtke</user> <email>hradtke@php.net</email> <active>yes</active> </lead> <date>2011-12-05</date> <time>16:41:40</time> <version> <release>1.0.1</release> <api>1.0.1</api> </version> <stability> <release>stable</release> <api>stable</api> </stability> Saturday, April 14, 12
  102. package.xml <license uri="http://www.php.net/license">PHP</license> <notes> - Fixed PECL Bug #60438 (wrong

    version number in php_gearman.h) </notes> <contents> <dir name="/"> <file md5sum="da6d77a214aa6239b68efdbe2b12fd61" name="examples/image_thumbnail_client_bg.php" role="doc" /> <file md5sum="bdda0aa48d9df805b7cb333d1d986d62" name="examples/image_thumbnail_client.php" role="doc" /> <file md5sum="4c6afcfb3c9614c8f67e62ca77c9d93b" name="examples/image_thumbnail_client_task.php" role="doc" /> <file md5sum="828cc27885029474707acda417f15d16" name="examples/image_thumbnail_worker.php" role="doc" /> <file md5sum="8b868e03769c9422ca6891f440105359" name="examples/reverse_client_bg.php" role="doc" /> <file md5sum="3b344e946e0f0fe061ec34472e5f5fc2" name="examples/reverse_client.php" role="doc" /> <file md5sum="dbd0e80feebfc6f411556716e6339afc" name="examples/reverse_client_task.php" role="doc" /> <file md5sum="90be1117d2a4b2ccd79962ec6bb6e8bf" name="examples/reverse_worker.php" role="doc" /> <file md5sum="3171f70cb81342ee73acd90107bfccbb" name="EXPERIMENTAL" role="doc" /> <file md5sum="bf5270ef67ddf5132999761937755146" name="README" role="doc" /> <file md5sum="1eaa5362eb94b86ac3aaf63d4bb1b1e8" name="CREDITS" role="doc" /> <file md5sum="0e964e9273c606c46afbd311b5ad4d77" name="LICENSE" role="doc" /> <file md5sum="1edac7f37568b77870f60bb8d6fdccd0" name="ChangeLog" role="doc" /> <file md5sum="2965d6db29b2ca681b03ecb09fff689a" name="test_client.php" role="doc" /> <file md5sum="8e194fc11fb0ff5b2ef96f16758060aa" name="test_worker.php" role="doc" /> <file md5sum="7bcde7f5f213cb48e48c62ee9a948240" name="config.m4" role="src" /> <file md5sum="72b72fc3dc25f6b6b9d94acf9f3818a4" name="php_gearman.c" role="src" /> <file md5sum="4a0c4f71d316b31a5e8230abef7132eb" name="php_gearman.h" role="src" /> <file md5sum="c1c60600b416889269c65bf1a72b5862" name="gearman_001.phpt" role="test" /> </dir> </contents> Saturday, April 14, 12
  103. package.xml <dependencies> <required> <php> <min>5.1.0</min> <max>6.0.0</max> <exclude>6.0.0</exclude> </php> <pearinstaller> <min>1.4.0b1</min>

    </pearinstaller> </required> </dependencies> <providesextension>gearman</providesextension> <extsrcrelease /> <changelog> <release> <stability> <release>stable</release> <api>stable</api> </stability> <version> <release>1.0.1</release> <api>1.0.1</api> </version> <date>2011-12-05</date> <notes> - Fixed PECL Bug #60438 (wrong version number in php_gearman.h) </notes> </release> .... cut .... </package> Saturday, April 14, 12
  104. 你暈了嗎 Saturday, April 14, 12

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

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

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

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

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

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

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

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

    • 無清楚的文件 • 操作繁瑣,必須⼀一行行依照詢問輸入 • XML Tag 順序不對,就無法建置 • 雖然可以用 composer ,但卻是另外的生 態系統。 Saturday, April 14, 12
  113. Saturday, April 14, 12

  114. Saturday, April 14, 12

  115. 小結 Saturday, April 14, 12

  116. CPAN • 自由且開放: 任何人都可以快速發佈自己 的作品 • 多樣性: ⼀一種目的多種原型、實作,開發 者能有更多的選擇 •

    完整的測試系統: 不會隨便亂炸掉 • 以簡馭繁 Saturday, April 14, 12
  117. PEAR • 封閉: 上傳套件必須審核審核再審核 • 小團體: PEAR Team < 20

    人 • 無系統化測試 • 不友善的 Issue Tracker • 設計複雜、繁瑣 Saturday, April 14, 12
  118. 如果是如此,該如何改善呢 ? If so, how to improve the PHP package

    system ? Saturday, April 14, 12
  119. The Recent tools • Pyrus: pear2.php.net, is not opened yet.

    但工具本 身仍在 Alpha stage. • bundle install = Hack • 仍是使用 package.xml Saturday, April 14, 12
  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
  121. • 需要⼀一個更簡潔的套件定義檔案 Saturday, April 14, 12

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

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

    • 需能管理套件相依性,如 Bundler Saturday, April 14, 12
  124. We Can Do Better Saturday, April 14, 12

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

  126. The package.ini File [package] name = PackageName desc = description

    version = 1.2.0 author = “c9s <cornelius.howl@gmail.com>” channel = pear.host.com Saturday, April 14, 12
  127. The package.ini File [package] name = PackageName desc = description

    version = 1.2.0 author = “c9s <cornelius.howl@gmail.com>” channel = pear.host.com 5+ lines to create a package. Saturday, April 14, 12
  128. How to use it? • Put your class files in

    `src/` • Tests in `tests/` • documentation in `doc/` Saturday, April 14, 12
  129. 妥善配置 Class path Saturday, April 14, 12

  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
  131. PHP Standard Working Group Saturday, April 14, 12

  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
  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
  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
  135. Saturday, April 14, 12

  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
  137. Bundle packages $ onion bundle # install packages into vendor/

    dir. Saturday, April 14, 12
  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
  139. 建置 Autoload Script Saturday, April 14, 12

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

    14, 12
  141. SPL ClassLoader # autoload.php <?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
  142. SPL ClassLoader # autoload.php <?php require 'Universal/ClassLoader/BasePathClassLoader.php'; $loader = new

    \Universal\ClassLoader \BasePathClassLoader( array( 'src', 'vendor/pear' )); $loader->useIncludePath(true); $loader->register(); Saturday, April 14, 12
  143. 打包 㱺 Standalone executable Saturday, April 14, 12

  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
  145. To build a standalone binary $ ./package.phar Saturday, April 14,

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

  147. To build a standalone binary <?php require 'bundle.phar'; ?> Saturday,

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

    Client Client Saturday, April 14, 12
  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
  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
  151. Conclusion • PHP 生態系統雖先天不足,但 PHP 開發者及市場 仍相當大。 最近兩年 PSR (PHP

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

    Standard Group - Framework Developers) 逐漸在發展共通的規範, 達到元件 reuse 的目的。 • Composer 雖是獨立的生態系統,且目前主要用 於 Symfony,但可期待未來的發展。 • 期待 PHP 生態系統能有更好的改善 ~CoffeePHP ? Saturday, April 14, 12
  153. Q & A Thanks! cornelius.howl@gmail.com Twitter: http://twitter.com/c9s GitHub: http://github.com/c9s Saturday,

    April 14, 12