set() public method

public set ( $methods, $url, $callback = null )
Exemplo n.º 1
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     $_SERVER['REQUEST_METHOD'] = 'GET';
     router::route('/blog/:arg', function ($arg) {
         echo 'Argument: ' . $arg;
     }, 'GET', 'blog');
     router::route('/blog/*', function () {
         echo 'CatchAll';
     });
     router::route('/blog/arg', function () {
         echo 'NoArg';
     });
     router::route('/test.php', function () {
         echo 'test.php';
     });
     router::route('/proiecs/aed[]te\\*', function () {
         echo '/proiecs/aed[]te\\*';
     });
     router::route('/proiecs/:ala/bala/:korhaz/:edit/:buha', function ($arg1, $arg2, $arg3) {
         echo 'proiecs ' . $arg1 . $arg2 . $arg3;
     }, 'GET', 'proiecs');
     router::route('/proiecs/asfv', function () {
         echo '/proiecs/asfv/';
     });
     router::route(' /infinity', function () {
         echo 'infinity';
     }, 'GET', 'infinity');
     router::route('/infinity/ourubors/ternary', function () {
         echo '/infinity/ourubors/ternary';
     }, 'GET', 'infinity2');
     router::set('BASE', 'framework');
 }
Exemplo n.º 2
0
 public function loadTpl($tpl, $file = '', $time = 0)
 {
     mPHP::inc(MPHP_PATH . 'inc/functions.php');
     //加载常用函数集
     ob_start();
     $arrData = $this->_include($tpl, $file);
     ob_end_clean();
     if (!mPHP::$debug) {
         if ($this->is_merger) {
             $arrData['html'] = $this->merger($arrData['html']);
         }
         if ($this->is_mini_html) {
             $arrData['html'] = mini_html($arrData['html']);
         }
     }
     //路由缓存逻辑
     if ($time && !empty(mPHP::$CFG['router'])) {
         $ctime = $_SERVER['REQUEST_TIME'];
         $date = date('Y-m-d H:i:s');
         $arrData['html'] .= "<!-- mPHP html cache {$date} -->";
         $strDir = dirname($arrData['file']);
         if (!is_dir($strDir)) {
             mkdir($strDir, 0775, true);
         }
         file_put_contents($arrData['file'], $arrData['html']);
         mPHP::header('Cache-Control', 'max-age=0');
         mPHP::header('Last-Modified', date("D, d M Y H:i:s", $ctime));
         $data = array('ctime' => $ctime, 'etime' => $ctime + $time, 'file' => $arrData['file']);
         router::set($data);
     }
     echo $arrData['html'];
 }