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


PHP Slim::configureMode方法代码示例

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


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

示例1: Slim

<?php

// Initialize flags, config, models, cache, etc.
require_once 'init.php';
require_once BASE_DIR . '/vendor/Slim/Slim/Slim.php';
require_once BASE_DIR . '/vendor/Slim-Extras/Log Writers/TimestampLogFileWriter.php';
$app = new Slim(array('mode' => defined('PRODUCTION') ? 'production' : 'development', 'debug' => false, 'log.enabled' => true, 'log.writer' => new TimestampLogFileWriter(array('path' => BASE_DIR, 'name_format' => '\\s\\l\\i\\m\\_\\l\\o\\g'))));
$app->configureMode('development', function () use($app) {
    $app->config(array('debug' => true));
});
$app->configureMode('production', function () use($app) {
    error_reporting(0);
    $app->notFound(function () use($app) {
        $page = new ErrorController(404);
        $page->render();
    });
    $app->error(function (Exception $e) use($app) {
        $app->response()->status(500);
        if (!$app->request()->isAjax()) {
            $page = new ErrorController(500);
            $page->render();
        }
        $app->stop();
        if (file_exists(BASE_DIR . '/.gbemail')) {
            foreach (explode('\\n', file_get_contents(BASE_DIR . '/.gbemail')) as $email) {
                mail(trim($email), "GetchaBooks Error", get_error_message($e));
            }
        }
    });
});
$app->hook('slim.before', function () use($app) {
开发者ID:therealchiko,项目名称:getchabooks,代码行数:31,代码来源:index.php

示例2: mode_prod

// ORM::configure('setting_name', 'value_for_setting');
// ORM::configure('id', 'primary_key');
// ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
/**
 *  Instantiante Slim instance
 */
$app = new Slim(array('view' => new TwigView(), 'templates.path' => APPATH . '/templates', 'mode' => 'prod'));
/**
 *  Setup Sessions with Slim
 */
$app->add(new Slim_Middleware_SessionCookie(), array('expires' => '20 minutes', 'path' => '/', 'domain' => null, 'secure' => false, 'httponly' => false, 'name' => 'slim_session', 'secret' => SECRET, 'cipher' => MCRYPT_RIJNDAEL_256, 'cipher_mode' => MCRYPT_MODE_CBC));
/**
 * Production mode config settings
 * 
 */
function mode_prod()
{
    global $app;
    $app->config(array('log.enable' => true, 'log.path' => ABSPATH . 'logs', 'debug' => false));
}
$app->configureMode('prod', 'mode_production');
/**
 * Development mode config settings
 * 
 */
function mode_dev()
{
    global $app;
    $app->config(array('log.enable' => false, 'debug' => true));
}
$app->configureMode('dev', 'mode_development');
开发者ID:hbattat,项目名称:my-scripts,代码行数:31,代码来源:config.php

示例3: recall_template

/* == *
 *
 * SLIM INIT
 *
 * ==============================================*/
$app = new Slim(array('mode' => 'dev', 'templates.path' => 'templates', 'view' => $index_view, 'cookies.secret_key' => 'r+hhiXlmC4NvsQpq/jaZPK6h+sornz0LC3cbdJNj', 'cookies.cipher' => MCRYPT_RIJNDAEL_256, 'cookies.cipher_mode' => MCRYPT_MODE_CBC, 'cookies.secure' => false));
// set name
//$app->setName('reviewApp');
// End SLIM INIT
/* == *
 *
 * CONFIGS
 *
 * ==============================================*/
$app->configureMode('prod', function () use($app) {
    $app->config(array('log.enable' => true, 'log.path' => '../logs', 'debug' => false));
});
$app->configureMode('dev', function () use($app) {
    $app->config(array('log.enable' => false, 'debug' => true));
});
// End CONFIGS
/* == *
 *
 * UTILS
 *
 * ==============================================*/
// recall template
function recall_template()
{
    $template_path = $app->config('templates.path');
    //returns "../templates"
开发者ID:nerdfiles,项目名称:slim_bp,代码行数:31,代码来源:index.php

示例4: testModeConfigurationWhenNotCallable

 /**
  * Test mode configuration when not callable
  */
 public function testModeConfigurationWhenNotCallable()
 {
     $flag = 0;
     $s = new Slim(array('mode' => 'production'));
     $s->configureMode('production', 'foo');
     $this->assertEquals(0, $flag);
 }
开发者ID:rs3d,项目名称:Slimplr,代码行数:10,代码来源:SlimTest.php

示例5: testSlimLoggerInMode

 /**
  * Test Slim Logging for given mode
  *
  * Pre-conditions:
  * Slim app instantiated;
  * Set custom Logger for current app mode;
  *
  * Post-conditions:
  * Slim app Logger correct based on mode;
  */
 public function testSlimLoggerInMode()
 {
     $app = new Slim(array('mode' => 'test'));
     $app->configureMode('test', function () use($app) {
         $app->config(array('log.enable' => true, 'log.logger' => new CustomLogger()));
     });
     $app->configureMode('development', function () use($app) {
         $app->config(array('log.enable' => true));
     });
     $this->assertTrue($app->getLog()->getLogger() instanceof CustomLogger);
 }
开发者ID:inscriptionweb,项目名称:lebonmail,代码行数:21,代码来源:SlimTest.php

示例6: authenticate

<?php

require_once 'slim/Slim.php';
require_once 'slim/SmartyView.php';
require_once 'classes/app.php';
$app = new Slim(array('templates.path' => 'templates', 'view' => 'SmartyView', 'log.path' => 'slim/Logs', 'log.level' => 4, 'cookies.secret_key' => "[SALT]", 'mode' => 'development'));
$app->configureMode('production', function () use($app) {
    $app->config(array('log.enable' => true, 'debug' => false));
});
$app->configureMode('development', function () use($app) {
    $app->config(array('log.enable' => true, 'debug' => true));
});
//# Set your API_Key and Client secret                #//
//#   Available here: https://eventbrite.com/api/key  #//
$app->config('api_key', 'YOUR_API_KEY_HERE');
$app->config('client_secret', 'YOUR_CLIENT_SECRET_HERE');
function authenticate()
{
    $app = Slim::getInstance();
    if (!App::user()) {
        $app->redirect("/connect/");
    }
}
//## ROUTES ##//
$app->get('/', function () use($app) {
    $params = App::start();
    $params['title'] = "Home";
    $params['page'] = "home";
    if (!App::user()) {
        $params['button'] = "Connect";
    } else {
开发者ID:ryanj,项目名称:The-Event-Day,代码行数:31,代码来源:index.php

示例7: testSlimModeDefault

 /**
  * Test Slim mode with default
  *
  * Pre-conditions:
  * ENV[SLIM_MODE] not set;
  * Slim app initialized without config mode;
  *
  * Post-conditions:
  * Only the development configuration is called;
  */
 public function testSlimModeDefault()
 {
     $this->expectOutputString('dev mode');
     Slim::init();
     Slim::configureMode('development', function () {
         echo "dev mode";
     });
     Slim::configureMode('production', function () {
         echo "production mode";
     });
 }
开发者ID:alanvivona,项目名称:scawTP,代码行数:21,代码来源:SlimTest.php


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