當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Slim::root方法代碼示例

本文整理匯總了PHP中Slim::root方法的典型用法代碼示例。如果您正苦於以下問題:PHP Slim::root方法的具體用法?PHP Slim::root怎麽用?PHP Slim::root使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Slim的用法示例。


在下文中一共展示了Slim::root方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetRoot

 /**
  * Test get filesystem path to Slim app root directory
  */
 public function testGetRoot()
 {
     $_SERVER['DOCUMENT_ROOT'] = dirname(__FILE__);
     //<-- No trailing slash
     $s = new Slim();
     $this->assertEquals($_SERVER['DOCUMENT_ROOT'] . '/foo/', $s->root());
     //<-- Appends physical app path with trailing slash
 }
開發者ID:rs3d,項目名稱:Slimplr,代碼行數:11,代碼來源:SlimTest.php

示例2: render

 /**
  * Render a template
  *
  * Call this method within a GET, POST, PUT, DELETE, or NOT FOUND
  * callback to render a template, whose output is appended to the
  * current HTTP response body. How the template is rendered is
  * delegated to the current View.
  *
  * @param string 	$template 	The name of the template passed into the View::render method
  * @param array 	$data 		Associative array of data passed for the View
  * @param int 		$status 	The HTTP response status code to use (Optional)
  */
 public static function render($template, $data = array(), $status = null)
 {
     //TODO: Abstract setting the templates directory into Slim::set('templates', '/path') in Phase 3
     self::view()->templatesDirectory(Slim::root() . 'templates');
     if (!is_null($status)) {
         self::response()->status($status);
     }
     self::view()->data($data);
     self::view()->render($template);
 }
開發者ID:kolanos,項目名稱:Slim,代碼行數:22,代碼來源:Slim.php

示例3: testRootPathInSubDirectory

 /**
  * Test Slim Root From Subdirectory
  *
  * Pre-conditions:
  * Slim app instantiated;
  * Slim app installed in a physical, public subdirectory of document root;
  *
  * Post-conditions:
  * Slim correctly reports root path;
  */
 public function testRootPathInSubDirectory()
 {
     $_SERVER['REQUEST_URI'] = '/foo/bar';
     $_SERVER['SCRIPT_NAME'] = '/foo/bootstrap.php';
     $_SERVER['PHP_SELF'] = '/foo/bootstrap.php';
     $rootPath = rtrim($_SERVER['DOCUMENT_ROOT'], '/') . '/foo/';
     $app = new Slim();
     $this->assertEquals($rootPath, $app->root());
 }
開發者ID:inscriptionweb,項目名稱:lebonmail,代碼行數:19,代碼來源:SlimTest.php


注:本文中的Slim::root方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。