当前位置: 首页>>代码示例>>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;未经允许,请勿转载。