当前位置: 首页>>代码示例>>PHP>>正文


PHP Slim::environment方法代码示例

本文整理汇总了PHP中Slim::environment方法的典型用法代码示例。如果您正苦于以下问题:PHP Slim::environment方法的具体用法?PHP Slim::environment怎么用?PHP Slim::environment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Slim的用法示例。


在下文中一共展示了Slim::environment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testErrorHandlerUsesCurrentResponseObject

 /**
  * Test custom error handler uses existing Response object
  */
 public function testErrorHandlerUsesCurrentResponseObject()
 {
     $s = new Slim(array('debug' => false));
     $s->error(function (Exception $e) use($s) {
         $r = $s->response();
         $r->status(503);
         $r->write('Foo');
         $r['X-Powered-By'] = 'Slim';
         echo 'Bar';
     });
     $s->get('/bar', function () {
         throw new Exception('Foo');
     });
     $env = $s->environment();
     list($status, $header, $body) = $s->call($env);
     $this->assertEquals(503, $status);
     $this->assertEquals('FooBar', $body);
     $this->assertEquals('Slim', $header['X-Powered-By']);
 }
开发者ID:nerdfiles,项目名称:slim_bp,代码行数:22,代码来源:SlimTest.php

示例2: testSetFlashForCurrentRequest

 public function testSetFlashForCurrentRequest()
 {
     $s = new Slim();
     $s->get('/bar', function () use($s) {
         $s->flashNow('info', 'bar');
     });
     $s->run();
     $env = $s->environment();
     $this->assertEquals('bar', $env['slim.flash']['info']);
 }
开发者ID:rs3d,项目名称:Slimplr,代码行数:10,代码来源:SlimTest.php

示例3: Slim

<?php

// require stuffs
require 'vendors/Slim/Slim/Slim.php';
require 'vendors/Slim-Extras/Views/MustacheView.php';
require 'vendors/couchsimple.php';
// set up the app
MustacheView::$mustacheDirectory = 'vendors';
$app = new Slim(array('view' => 'MustacheView'));
$env = $app->environment();
$app->view()->appendData(array('app_title' => 'Couchbase Beers', 'base_url' => $env['SCRIPT_NAME'], 'current_url' => $env['PATH_INFO']));
// Setup Couchbase connected objects
try {
    $cb = new Couchbase("127.0.0.1:9000", "Administrator", "asdasd", "beer-sample");
} catch (ErrorException $e) {
    die($e->getMessage());
}
$cbv = new CouchSimple(array('host' => '127.0.0.1', 'port' => 9500));
// openbeers application goodness
// GET route
$app->get('/', function () use($app) {
    $content = $app->view()->render('index.mustache');
    $app->render('layout.mustache', compact('content'));
});
// beer routes
require_once 'beers.php';
// brewery routes
require_once 'breweries.php';
// run, Slim, run
$app->run();
开发者ID:bcui6611,项目名称:couchbase-beers,代码行数:30,代码来源:index.php


注:本文中的Slim::environment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。