2011年8月27日 星期六

Yii-1

  1. 前往MAMP網頁根目錄:
    cd /Applications/MAMP/htdocs
  2. 執行yiic腳本,產生 demo 網頁應用程式(不要用 sudo):
    ./yii//framework/yiic webapp demo
    Password:
    Create a Web application under '/Applications/MAMP/htdocs/demo'? [Yes|No] y
  3. 測試 demo :
    http://localhost/demo/index.php
  4. 執行 yiic shell , 要指定 config 檔案路徑:
    ./protected/yiic shell ./protected/config/main.php
  5. 產生 message 控制器與 helloWorld 函數:
    >> controller message helloWorld
  6. 測試 message 控制器與 helloWorld 函數:
    http://localhost/demo/index.php?r=message
    http://localhost/demo/index.php?r=message/helloWorld

2011年8月22日 星期一

MAMP 2.0 透過 pear 安裝 PHPUnit

    根據這一篇的說明:http://ericlbarnes.com/blog/post/php_pear_phpunit_mamp
    1. 刪除 MAMP 2.0.x 錯誤的設定檔:
      sudo rm /Applications/MAMP/bin/php/php5.3.6/conf/pear.conf
    2. 前往MAMP的PEAR腳本檔案夾:
      MAMP 1.9.x:
      cd /Applications/MAMP/bin/php5.3/bin/
      
      MAMP 2.0.x:
      cd /Applications/MAMP/bin/php/php5.3.6/bin/
      
    3. 更新MAMP的PEAR:
      sudo ./pear channel-update pear.php.net
      sudo ./pear upgrade pear
    4. 檢查PEAR版本:
      ./pear -V
      PEAR Version: 1.9.4
      PHP Version: 5.3.6
    5. 安裝PHPUnit:
      sudo ./pear channel-discover pear.phpunit.de
      sudo ./pear channel-discover components.ez.no
      sudo ./pear channel-discover pear.symfony-project.com
      sudo ./pear install --alldeps phpunit/PHPUnit
    6. 檢查PEAR套件:
      ./pear list
      Installed packages, channel pear.php.net:
      =========================================
      Package          Version State
      Archive_Tar      1.3.7   stable
      Cache_Lite       1.7.12  stable
      Console_Getopt   1.3.1   stable
      PEAR             1.9.4   stable
      Structures_Graph 1.0.4   stable
      XML_Util         1.2.1   stable
    7. 製作終端機可執行的 phpunit 捷徑:
      MAMP 1.9.x
      sudo ln -s /Applications/MAMP/bin/php5.3/bin/phpunit /usr/bin/phpunit
      MAMP 2.0.x
      sudo ln -s /Applications/MAMP/bin/php/php5.3.6/bin/phpunit /usr/bin/phpunit
    8. 安裝 vfStream :
      sudo ./pear channel-discover pear.php-tools.net
      sudo ./pear install pat/vfsStream-alpha
      
    9. 測試 phpunit 捷徑:
      phpunit
      PHPUnit 3.5.15 by Sebastian Bergmann.
      
      Usage: phpunit [switches] UnitTest [UnitTest.php]
             phpunit [switches] 
      ....