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


PHP Slim::configureMode方法代码示例

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


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

示例1: configureSlim

 /**
  * Apply settings to the Slim application.
  *
  * @param \Slim\Slim $slim Application
  */
 protected function configureSlim(\Slim\Slim $slim)
 {
     $slim->config(['parsoid.url' => Config::getStr('PARSOID_URL', 'http://parsoid-lb.eqiad.wikimedia.org/enwiki/'), 'parsoid.cache' => Config::getStr('CACHE_DIR', "{$this->deployDir}/data/cache"), 'es.url' => Config::getStr('ES_URL', 'http://127.0.0.1:9200/')]);
     $slim->configureMode('production', function () use($slim) {
         $slim->config(['debug' => false, 'log.level' => Config::getStr('LOG_LEVEL', 'INFO')]);
         // Install a custom error handler
         $slim->error(function (\Exception $e) use($slim) {
             $errorId = substr(session_id(), 0, 8) . '-' . substr(uniqid(), -8);
             $slim->log->critical($e->getMessage(), ['exception' => $e, 'errorId' => $errorId]);
             $slim->view->set('errorId', $errorId);
             $slim->render('error.html');
         });
     });
     $slim->configureMode('development', function () use($slim) {
         $slim->config(['debug' => true, 'log.level' => Config::getStr('LOG_LEVEL', 'DEBUG'), 'view.cache' => false]);
     });
 }
开发者ID:bd808,项目名称:SAL,代码行数:22,代码来源:App.php

示例2: configureSlim

 /**
  * Apply settings to the Slim application.
  *
  * @param \Slim\Slim $slim Application
  */
 protected function configureSlim(\Slim\Slim $slim)
 {
     $slim->config(array('parsoid.url' => Config::getStr('PARSOID_URL', 'http://parsoid-lb.eqiad.wikimedia.org/enwiki/'), 'parsoid.cache' => Config::getStr('CACHE_DIR', "{$this->deployDir}/data/cache"), 'es.url' => Config::getStr('ES_URL', 'http://127.0.0.1:9200/'), 'es.user' => Config::getStr('ES_USER', ''), 'es.password' => Config::getStr('ES_PASSWORD', ''), 'can.edit' => Config::getBool('CAN_EDIT', false), 'can.vote' => Config::getBool('CAN_VOTE', false), 'oauth.enable' => Config::getBool('USE_OAUTH', false), 'oauth.consumer_token' => Config::getStr('OAUTH_CONSUMER_TOKEN', ''), 'oauth.secret_token' => Config::getStr('OAUTH_SECRET_TOKEN', ''), 'oauth.endpoint' => Config::getStr('OAUTH_ENDPOINT', ''), 'oauth.redir' => Config::getStr('OAUTH_REDIR', ''), 'oauth.callback' => Config::getStr('OAUTH_CALLBACK', '')));
     $slim->configureMode('production', function () use($slim) {
         $slim->config(array('debug' => false, 'log.level' => Config::getStr('LOG_LEVEL', 'INFO')));
         // Install a custom error handler
         $slim->error(function (\Exception $e) use($slim) {
             $errorId = substr(session_id(), 0, 8) . '-' . substr(uniqid(), -8);
             $slim->log->critical($e->getMessage(), array('exception' => $e, 'errorId' => $errorId));
             $slim->view->set('errorId', $errorId);
             $slim->render('error.html');
         });
     });
     $slim->configureMode('development', function () use($slim) {
         $slim->config(array('debug' => true, 'log.level' => Config::getStr('LOG_LEVEL', 'DEBUG'), 'view.cache' => false));
     });
 }
开发者ID:bd808,项目名称:quips,代码行数:22,代码来源:App.php

示例3: configureModes

 public static function configureModes(Slim $app, array $modeConfigs)
 {
     foreach ($modeConfigs as $mode => $config) {
         $app->configureMode($mode, function () use($app, $config) {
             $app->config($config);
         });
     }
 }
开发者ID:fousheezy,项目名称:slim-core,代码行数:8,代码来源:Mode.php

示例4: configureApp

 protected function configureApp(Slim $app, Container $c)
 {
     // Add Middleware
     $app->add($c['profileMiddleware']);
     $app->add($c['navigationMiddleware']);
     $app->add($c['authenticationMiddleware']);
     $app->add($c['sessionCookieMiddleware']);
     // Prepare view
     $app->view($c['twig']);
     $app->view->parserOptions = $this['config']['twig'];
     $app->view->parserExtensions = array($c['slimTwigExtension'], $c['twigExtensionDebug']);
     $config = $this['config'];
     // Dev mode settings
     $app->configureMode('development', function () use($app, $config) {
         $app->config(array('log.enabled' => true, 'log.level' => Log::DEBUG));
         $config['twig']['debug'] = true;
     });
 }
开发者ID:neophyt3,项目名称:flaming-archer,代码行数:18,代码来源:Container.php

示例5: dirname

use Slim\Views\Twig;
use Slim\Views\TwigExtension;
use Noodlehaus\Config;
use Myproject\User\User;
use Myproject\Helpers\Hash;
use Myproject\Validation\Validator;
use Myproject\Middleware\BeforeMiddleware;
session_cache_limiter(false);
session_start();
ini_set('display_errors', 'On');
define(INC_ROOT, dirname(__DIR__));
require INC_ROOT . '/vendor/autoload.php';
$app = new Slim(['mode' => file_get_contents(INC_ROOT . '/mode.php'), 'view' => new Twig(), 'templates.path' => INC_ROOT . '/app/views']);
$app->add(new BeforeMiddleware());
$app->configureMode($app->config('mode'), function () use($app) {
    $app->config = Config::load(INC_ROOT . "/app/config/{$app->mode}.php");
});
require 'database.php';
require 'routes.php';
$app->auth = false;
$app->container->set('user', function () {
    return new User();
});
$app->container->singleton('hash', function () use($app) {
    return new Hash($app->config);
});
$app->container->singleton('validation', function () use($app) {
    return new Validator($app->user);
});
$view = $app->view;
$view->parserOptions = ['debug' => $app->config->get('twig.debug')];
开发者ID:bogiesoft,项目名称:php-auth,代码行数:31,代码来源:start.php

示例6: Slim

use OpenTok\OpenTok;
use OpenTok\Role;
use werx\Config\Providers\ArrayProvider;
use werx\Config\Container;
/* ------------------------------------------------------------------------------------------------
 * Slim Application Initialization
 * -----------------------------------------------------------------------------------------------*/
$app = new Slim(array('log.enabled' => true));
/* ------------------------------------------------------------------------------------------------
 * Configuration
 * -----------------------------------------------------------------------------------------------*/
$provider = new ArrayProvider('../config');
$config = new Container($provider);
// Environment Selection
$app->configureMode('development', function () use($config) {
    $config->setEnvironment('development');
});
$config->load(array('opentok'), true);
// Constants
define('NAME_MAX_LENGTH', '100');
/* ------------------------------------------------------------------------------------------------
 * OpenTok Initialization
 * -----------------------------------------------------------------------------------------------*/
$opentok = new OpenTok($config->opentok('key'), $config->opentok('secret'));
/* ------------------------------------------------------------------------------------------------
 * Routing
 * -----------------------------------------------------------------------------------------------*/
// Presence configuration
//
// Response: (JSON encoded)
// *  `apiKey`: The presence session API Key
开发者ID:pravarkulkarni,项目名称:presencekit-php,代码行数:31,代码来源:index.php

示例7: Slim

<?php

/**
 * app/bootstrap.php
 *
 * @author Zangue <armand.zangue@gmail.com>
 */
use Slim\Slim;
use Noodlehaus\Config;
//session_cache_limiter(false);
//session_start();
ini_set('display_errors', 'On');
// Require all PHP dependencies using the composer autoloader
require ROOT . DS . 'vendor' . DS . 'autoload.php';
require ROOT . DS . CORE_DIR . DS . 'Router.php';
require ROOT . DS . CORE_DIR . DS . 'Model' . DS . 'Model.php';
require ROOT . DS . CORE_DIR . DS . 'Model' . DS . 'ErrorModel.php';
require ROOT . DS . CORE_DIR . DS . 'Controller' . DS . 'Controller.php';
require ROOT . DS . CORE_DIR . DS . 'Controller' . DS . 'ErrorController.php';
require ROOT . DS . CORE_DIR . DS . 'View' . DS . 'View.php';
require APP_DIR . DS . 'Controller' . DS . 'AppController.php';
require APP_DIR . DS . 'Model' . DS . 'AppModel.php';
// Instantiate a new Slim Application
$app = new Slim(['mode' => 'development', 'templates.path' => VIEW_ROOT]);
// Some more things can be done here. Eg, add a custom middleware
// $app->add(new MyMiddleware());
// Load configuration
$app->configureMode($app->config('mode'), function () use($app) {
    $app->config = Config::load(APP_DIR . DS . "Config" . DS . "{$app->mode}.php");
});
开发者ID:zangue,项目名称:slimvc,代码行数:30,代码来源:bootstrap.php

示例8: dirname

// use CRB\Cert\Cert;
use CRB\Mail\Mailer;
use CRB\Helpers\Hash;
use CRB\Validation\Validator;
use CRB\Middleware\BeforeMiddleware;
use CRB\Middleware\CsrfMiddleware;
session_cache_limiter(false);
session_start();
ini_set('display_errors', 'On');
define('INC_ROOT', dirname(__DIR__));
require INC_ROOT . '/vendor/autoload.php';
$app = new Slim(['mode' => file_get_contents(INC_ROOT . '/mode.php'), 'view' => new Twig(), 'templates.path' => INC_ROOT . '/app/views']);
$app->add(new BeforeMiddleware());
$app->add(new CsrfMiddleware());
$app->configureMode($app->config('mode'), function () use($app) {
    $mode = preg_replace('/\\s+/', '', $app->mode);
    $app->config = Config::load(INC_ROOT . "/app/config/{$mode}.php");
});
require 'database.php';
require 'filters.php';
require 'routes.php';
$app->auth = false;
$app->container->set('user', function () {
    return new User();
});
// $app->container->set('cert', function() {
//   return new Cert;
// });
$app->container->singleton('hash', function () use($app) {
    return new Hash($app->config);
});
$app->container->singleton('validation', function () use($app) {
开发者ID:samuelchristopher,项目名称:CRB,代码行数:32,代码来源:start.php

示例9: array

// You can add an environment variable to your local php.ini call APPLICATION_ENV and set it to 'dev'.  This allows you to have the settings of the system change from Dev to Stage or Production based on if it's on your local machine or on a server.  This is helpful when you don't want to remember to turn debugging on and off in your app, and you have database settings that change depending on if it's on the server or not.
//$appMode = getenv("APPLICATION_ENV");
$appMode = "dev";
if ($appMode !== 'dev') {
    $appMode = 'prod';
}
// This logger will write a file for each day of logs.
$logHandlers = array(new \Monolog\Handler\StreamHandler('./logs/' . date('Y-m-d') . '.log'));
if ($appMode !== 'dev') {
    //$logHandlers[]= new \Monolog\Handler\LogglyHandler('loggly api key');
}
$logger = new \Flynsarmy\SlimMonolog\Log\MonologWriter(array('handlers' => $logHandlers, 'processors' => array(new \Monolog\Processor\WebProcessor($_SERVER))));
$app = new Slim(array('mode' => $appMode, 'log.writer' => $logger, 'templates.path' => './views'));
// Only invoked if mode is "prod"
$app->configureMode('prod', function () use($app) {
    $app->config(array('log.enable' => true, 'debug' => false));
});
// Only invoked if mode is "dev"
$app->configureMode('dev', function () use($app) {
    $app->config(array('log.enable' => true, 'debug' => true));
});
$config = Config::getInstance();
$config->setMode($appMode === 'dev' ? Config::DEVELOPMENT : Config::STAGING);
$app->contentType('application/json');
//$app->add(new OAuthVerifyMiddleware());
include 'routes/user.php';
/// ------------------------- ///
/// --- Utility Functions --- ///
/// ------------------------- ///
/**
 * Returns a formatted response to the requesting client.
开发者ID:earl3s,项目名称:Boilderplate-php-REST-API,代码行数:31,代码来源:index.php

示例10: dirname

use alexander\Helpers\Hash;
use alexander\Validation\Validator;
use alexander\Middleware\BeforeMiddleware;
use alexander\Middleware\CsrfMiddleware;
use alexander\Mail\Mailer;
session_cache_limiter(false);
session_start();
// only for tutorial
ini_set('display_errors', 'On');
define('INC_ROOT', dirname(__DIR__));
require INC_ROOT . '/vendor/autoload.php';
$app = new Slim(['mode' => file_get_contents(INC_ROOT . '/mode.php'), 'view' => new Twig(), 'templates.path' => INC_ROOT . '/app/views']);
$app->add(new BeforeMiddleware());
$app->add(new CsrfMiddleware());
$app->configureMode($app->config('mode'), function () use($app) {
    $app->config = Config::load(INC_ROOT . "/app/config/" . substr($app->mode, 0, strlen($app->mode) - 1) . ".php");
});
require 'database.php';
require 'filters.php';
require 'routes.php';
$app->auth = false;
// $user = new \alexander\user\user;
$app->container->set('user', function () {
    return new User();
});
$app->container->singleton('hash', function () use($app) {
    return new Hash($app->config);
});
$app->container->singleton('validation', function () use($app) {
    return new Validator($app->user, $app->hash, $app->auth);
});
开发者ID:ajtam,项目名称:auth-php,代码行数:31,代码来源:start.php

示例11: function

$app->setName('Holidays');
$app->container->singleton('db', function () {
    $database = new PDO("sqlite:" . APP_PATH . "../databases/database.sqlite");
    checkAndInitDatabase($database);
    return $database;
});
$app->container->singleton('periods', function () use($app) {
    return new Periods($app->db);
});
$app->container->singleton('allowances', function () use($app) {
    return new Allowances($app->db);
});
$view = $app->view();
$app->configureMode('production', function () use($app, $view) {
    (new Bootstrap($app, new PdoAdapter($app->db, 'users', 'user', 'hash', new PasswordValidator()), new acl()))->bootstrap();
    $app->config(array('log.enable' => true, 'templates.path' => '../templates', 'debug' => false));
    $view->parserOptions = array('debug' => false, 'cache' => dirname(__FILE__) . '/../cache', 'auto_reload' => true);
    $view->parserExtensions = array(new TwigExtension());
});
$app->configureMode('development', function () use($app, $view) {
    (new Bootstrap($app, new DebugAdapter(), new acl()))->bootstrap();
    $app->authenticator->authenticate("admin", "admin");
    $app->config(array('log.enable' => false, 'templates.path' => '../templates', 'debug' => true));
    $view->parserOptions = array('debug' => true, 'cache' => false);
    $view->parserExtensions = array(new TwigExtension(), new Twig_Extension_Debug());
});
$app->hook('slim.before.router', function () use($app) {
    if ($app->auth->hasIdentity()) {
        $authData = $app->auth->getIdentity();
        $authData['department_name'] = getNameForID($app->db, $authData['department']);
        $app->view()->appendData(array('userInfo' => $authData));
    }
开发者ID:greboid,项目名称:Holidays,代码行数:32,代码来源:index.php

示例12: catch

try {
    Config\Yaml::getInstance()->addFile($appRoot . '/src/xAPI/Config/Config.yml');
} catch (\Exception $e) {
    if (PHP_SAPI === 'cli' && (isset($argv[1]) && $argv[1] === 'setup:db' || isset($argv[0]) && !isset($argv[1]))) {
        // Database setup in progress, ignore exception
    } else {
        throw new \Exception('You must run the setup:db command using the X CLI tool!');
    }
}
// Use Mongo's native long int
ini_set('mongo.native_long', 1);
// Only invoked if mode is "production"
$app->configureMode('production', function () use($app, $appRoot) {
    // Add config
    Config\Yaml::getInstance()->addFile($appRoot . '/src/xAPI/Config/Config.production.yml');
    // Set up logging
    $logger = new Logger\MonologWriter(['handlers' => [new StreamHandler($appRoot . '/storage/logs/production.' . date('Y-m-d') . '.log')]]);
    $app->config('log.writer', $logger);
});
// Only invoked if mode is "development"
$app->configureMode('development', function () use($app, $appRoot) {
    // Add config
    Config\Yaml::getInstance()->addFile($appRoot . '/src/xAPI/Config/Config.development.yml');
    // Set up logging
    $logger = new Logger\MonologWriter(['handlers' => [new StreamHandler($appRoot . '/storage/logs/development.' . date('Y-m-d') . '.log')]]);
    $app->config('log.writer', $logger);
});
if (PHP_SAPI !== 'cli') {
    $app->url = Url::createFromServer($_SERVER);
}
// Error handling
开发者ID:rohanabraham,项目名称:lxHive,代码行数:31,代码来源:index.php

示例13: Slim

$app = new Slim(require_once ROOT . '/app/config/app.php');
$app->setName('RedSlim');
/*
 * set some globally available view-data
 */
$resourceUri = $_SERVER['REQUEST_URI'];
$rootUri = $app->request()->getRootUri();
$assetUri = $rootUri;
$app->view()->appendData(array('app' => $app, 'rootUri' => $rootUri, 'assetUri' => $assetUri, 'resourceUri' => $resourceUri));
// include all controllers
foreach (glob(ROOT . '/app/controllers/*.php') as $router) {
    include $router;
}
// disable fluid mode in production environment
$app->configureMode(SLIM_MODE_PRO, function () use($app) {
    // note, transactions will be auto-committed in fluid mode
    R::freeze(true);
});
/*
|--------------------------------------------------------------------------
| configure Twig
|--------------------------------------------------------------------------
|
| The application uses Twig as its template engine. This script configures
| the template paths and adds some extensions.
|
*/
$view = $app->view();
$view->parserOptions = array('debug' => true, 'cache' => false, 'auto_reload' => true);
$view->parserExtensions = array(new TwigExtension());
/*
|--------------------------------------------------------------------------
开发者ID:voku,项目名称:anti-xss--demo,代码行数:32,代码来源:start.php

示例14: dirname

use Slim\Slim;
use Slim\Views\Twig;
use Slim\Views\TwigExtension;
use Noodlehaus\Config;
use Codecourse\User\User;
use Codecourse\Helpers\Hash;
use Codecourse\Validation\Validator;
session_cache_limiter(false);
session_start();
ini_set('display_errors', 'On');
define('INC_ROOT', dirname(__DIR__));
require INC_ROOT . '/vendor/autoload.php';
$app = new Slim(['mode' => file_get_contents(INC_ROOT . '/mode.php'), 'view' => new Twig(), 'templates.path' => INC_ROOT . '/app/views']);
$app->configureMode($app->config('mode'), function () use($app) {
    $app->config = Config::load(INC_ROOT . "/app/config/{$app->mode}.php");
    // Pulls in the specific config we want to use from mode.php
});
require 'database.php';
require 'routes.php';
$app->container->set('user', function () {
    return new User();
});
$app->container->singleton('hash', function () use($app) {
    return new Hash($app->config);
});
$app->container->singleton('validation', function () use($app) {
    return new Validator($app->user);
});
$view = $app->view();
$view->parserOptions = ['debug' => $app->config->get('twig.debug')];
$view->parserExtensions = [new TwigExtension()];
开发者ID:samwisemurphy,项目名称:authentication,代码行数:31,代码来源:start.php

示例15: Slim

define("ASSETS_PATH", DOC_ROOT . "public/assets/");
define("IMAGE_PATH", ASSETS_PATH . "images/");
define("BANNER_PATH", ASSETS_PATH . "images/banners/");
require DOC_ROOT . 'vendor/autoload.php';
$app = new Slim(['mode' => file_get_contents(DOC_ROOT . 'mode.php'), 'view' => new Twig(), 'templates.path' => DOC_ROOT . 'app/views']);
$app->add(new BeforeMiddleware());
$app->add(new CsrfMiddleware());
$mode = $app->config('mode');
//development
if ($mode == "production") {
    $log = $app->getLog();
    $log->setEnabled(true);
    $log->setWriter(new LogWriter());
}
$app->configureMode($mode, function () use($app) {
    $app->config = Config::load(DOC_ROOT . "app/config/{$app->mode}.php");
});
$config = $app->config;
//$app->config('cookies.domain', $app->config->get('cookie.domain'));
$app->config(array('cookies.domain' => $config->get('cookie.domain'), 'cookies.httponly' => $config->get('cookie.httponly'), 'cookies.secret' => $config->get('cookie.secret')));
require 'database.php';
require 'filters.php';
require 'routes.php';
//echo $dbDriver = $config->get('db.host');
//$user = new  \Core\User\User;
//Make the user available everywhere
$app->container->set('user', function () {
    return new User();
});
$app->container->set('images', function () {
    return new Images();
开发者ID:harleybalo,项目名称:doan,代码行数:31,代码来源:start.php


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