CrossPHP 1.5.0 發佈, 功能加強及文檔完善

1.5.0 更新說明


一. 新增功能

  1. 增長Cross\Core\Delegate::on方法, 用於在框架執行流程中執行自定義函數php

    $web = Cross\Core\Delegate::loadApp('web');
    
       $web->on('dispatcher', function() use($web) {
           echo 'before dispatcher';
       });
       
       $web->on('obRender', function($content) use($web) {
           echo 'after obRender';
       });
    
       $web->run();
  2. 加強REST運行方式web

    $web = Cross\Core\Delegate::loadApp('web');        
       
       $rest = $web->rest();        
       $rest->get('/', function() {
           echo 'Hello CrossPHP!';
       });
       
       $rest->run();

    參數及正則驗證app

    $web = Cross\Core\Delegate::loadApp('web');
       
       $rest = $web->rest();
       $rest->rules(array(
           'name' => "/^\w+$/",
       ));
       
       $rest->get('/hi-{:name}', function ($name) {
           echo 'Hi ' . $name;
       });
       
       $rest->run();

    和MVC結合框架

    $web = Cross\Core\Delegate::loadApp('web');
       
       $rest = $web->rest();
       $rest->get('/', function () use ($web) {
           $web->get('main:index');
       });
       
       $rest->run();
  3. 增長數據表前綴配置, 在db.config.php中使用prefix指定, 手動拼接SQL時, 須要調用 $this->getPrefix('table') 來獲取完整表名, 其餘使用方式不變函數

  4. 修改了app的啓動方式, 加強了各app之間的獨立性, 調整了繼承關係, FrameBase再也不從Application繼承優化

二. BUG修復

  1. 修復mRun不能正確識別請求uri的bugthis

    $web = Cross\Core\Delegate::loadApp('web');
        $web->map('/hello', 'Main:index');
        $web->mRun();
    
    `map`和`mRun()`用於限制訪問, 只有在`map`中註冊的uri才生效

三. 優化及功能更新

  1. 運行在CLI模式下時,再也不發送HTTP頭spa

  2. Application::initController(), 更早捕獲異常rest

  3. 去掉Cross\Core\Delegate::cliRun()中的一箇中間變量code

  4. 調整cli模式下的異常模板

  5. 可見性及註釋調整

  6. 優化自動加載時對文件是否存在的判斷

  7. Router新增一個方法, 用於統一獲取請求URI

  8. 簡化config類, parse方法再也不支持文件

  9. rRun()方法的第一個參數, 只需實現RouterInterface接口. 取消rRun()的第二個參數

  10. 優化Response中的contentType設置

相關文章
相關標籤/搜索