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


PHP Slim::config方法代码示例

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


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

示例1: openDatabase

 /**
  * Open a database connection
  *
  * @param \Slim\Slim $app
  * @return \PDO
  */
 public static function openDatabase($app)
 {
     $dsn = $app->config('database.dsn');
     $user = $app->config('database.user');
     $pass = $app->config('database.pass');
     return new \PDO($dsn, $user, $pass);
 }
开发者ID:blueskyfish,项目名称:temperature-monitor,代码行数:13,代码来源:DB.php

示例2: refresh

 /**
  * Load config into slim configuration
  * @param Slim $app
  */
 public function refresh(Slim $app = null)
 {
     if ($app != null) {
         $this->app = $app;
     }
     $this->app->config($this->config);
 }
开发者ID:nogo,项目名称:framework,代码行数:11,代码来源:SlimLoader.php

示例3: setup

 /**
  * Setup the form service.
  *
  * @param \Slim\Slim $app The application instance.
  */
 public static function setup(Slim $app)
 {
     $app->container->singleton('form', function () use($app) {
         $prefix = $app->config('form.prefix');
         return new Form($prefix ?: null);
     });
 }
开发者ID:creativeduo,项目名称:thin,代码行数:12,代码来源:Form.php

示例4: addSettings

 /**
  * @param array $settings
  * @return $this
  */
 public function addSettings(array $settings)
 {
     foreach ($settings as $key => $value) {
         $this->app->config($key, $value);
     }
     return $this;
 }
开发者ID:stuartmclean,项目名称:my_website,代码行数:11,代码来源:SlimApp.php

示例5: run

 /**
  * @return $this
  */
 public function run()
 {
     require_once __DIR__ . '/../config/propel/config.php';
     //$this->config = Yaml::parse(file_get_contents(__DIR__ . '/../config/config.yml'));
     $this->routes = Yaml::parse(file_get_contents(__DIR__ . '/../config/routes.yml'))['routes'];
     $this->app = new \Slim\Slim();
     $this->app->config(['templates.path' => __DIR__ . '/Views/']);
     $this->oauth = $this->configureOAuth();
     $this->instantiateRoutes()->app->run();
     return $this;
 }
开发者ID:alexdevid,项目名称:slim-rest,代码行数:14,代码来源:Kernel.php

示例6: __construct

 public function __construct()
 {
     $slim = new Slim(['view' => new Twig()]);
     $slim->config(['templates.path' => __DIR__ . '/../../view']);
     $slim->view()->parserOptions = array('debug' => true, 'cache' => __DIR__ . '/../../compilation_cache');
     $slim->config(['content' => ['main_menu' => $this->getMainMenu()]]);
     global $config;
     ORM::configure("mysql:host={$config['host']};port={$config['port']};dbname={$config['db_name']}");
     ORM::configure('username', $config['db_user']);
     ORM::configure('password', $config['db_password']);
     ORM::configure('driver_options', [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8']);
     ORM::configure('error_mode', PDO::ERRMODE_EXCEPTION);
     $this->initSlimRoute();
 }
开发者ID:vsmihaylovsky,项目名称:teachdevelop.pp.ua,代码行数:14,代码来源:Application.php

示例7: setup

 /**
  * Setup the template service.
  *
  * @param \Slim\Slim $app The application instance.
  */
 public static function setup(Slim $app)
 {
     $debug = $app->config('debug');
     $view = $app->view(new Twig());
     $view->parserOptions = ['debug' => $debug, 'cache' => $app->config('view.cache_path')];
     $view->setTemplatesDirectory($app->config('view.path'));
     $view->parserExtensions = [new TwigExtension()];
     if ($debug) {
         $view->parserExtensions[] = new Twig_Extension_Debug();
     }
     $extensions = (array) $app->config('view.extensions');
     foreach ($extensions as $ext) {
         $view->parserExtensions[] = new $ext();
     }
 }
开发者ID:creativeduo,项目名称:thin,代码行数:20,代码来源:Template.php

示例8: enable

 public function enable(Slim $app)
 {
     $this->app = $app;
     $this->config = $this->app->config('api');
     $this->factory = new Factory($this->config['resources']);
     // Middleware
     $this->app->add(new Database());
     $this->app->add(new ApiMiddleware($this->config));
     // Routes
     $this->app->get($this->config['prefix'] . '/:resource/:id', [$this, 'getAction'])->conditions(['id' => '\\d+'])->name('resource_get');
     $this->app->get($this->config['prefix'] . '/:resource', [$this, 'listAction'])->name('resource_get_list');
     $this->app->put($this->config['prefix'] . '/:resource/:id', [$this, 'putAction'])->conditions(['id' => '\\d+'])->name('resource_put');
     $this->app->post($this->config['prefix'] . '/:resource', [$this, 'postAction'])->name('resource_post');
     $this->app->delete($this->config['prefix'] . '/:resource/:id', [$this, 'deleteAction'])->conditions(['id' => '\\d+'])->name('resource_delete');
 }
开发者ID:nogo,项目名称:api,代码行数:15,代码来源:ResourceController.php

示例9: render

 /**
  * Override \Slim\Slim::render method on controller
  *
  * @param string $tpl
  * @param array $data []
  * @param string $suffix
  * @return void
  */
 protected function render($tpl, array $data = [])
 {
     $suffix = $this->app->config('template.suffix');
     $suffix = empty($suffix) ? $this->viewSuffix : $suffix;
     $tpl .= $suffix;
     $this->app->render($tpl, $data);
 }
开发者ID:im286er,项目名称:slimore,代码行数:15,代码来源:Controller.php

示例10: 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

示例11: 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

示例12: __construct

 /**
  * Constructor for TodoQueue\Controller\Login
  *
  * @param \Slim\Slim $app Ref to slim app
  */
 public function __construct(\Slim\Slim &$app)
 {
     $this->app = $app;
     if ($renderTemplateSuffix = $app->config('controller.template_suffix')) {
         $this->renderTemplateSuffix = $renderTemplateSuffix;
     }
     if (!is_null($paramPrefix = $app->config('controller.param_prefix'))) {
         $this->paramPrefix = $paramPrefix;
         $prefixLength = strlen($this->paramPrefix);
         if ($prefixLength > 0 && substr($this->paramPrefix, -$prefixLength) !== '.') {
             $this->paramPrefix .= '.';
         }
     }
     if ($app->config('controller.cleanup_params')) {
         $this->paramCleanup = true;
     }
 }
开发者ID:andrearruda,项目名称:Farol-Sign-UOL-Feed,代码行数:22,代码来源:SlimController.php

示例13: 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

示例14: getFramework

 protected function getFramework($config)
 {
     $app = new Slim(['view' => new Twig()]);
     $app->config(['templates.path' => $config['templates.path']]);
     $view = $app->view();
     $view->parserOptions = $config['parserOptions'];
     $view->parserExtensions = array(new TwigExtension());
     return $app;
 }
开发者ID:jhnbrnn,项目名称:Sloop,代码行数:9,代码来源:Sloop.php

示例15: __construct

 public function __construct(StorageInterface $storage, Slim $app)
 {
     $this->storage = $storage;
     $this->app = $app;
     $this->ignored = $app->config('api.classes.auth.ignored');
     if (!is_array($this->ignored)) {
         $this->ignored = array();
     }
 }
开发者ID:dwsla,项目名称:deal,代码行数:9,代码来源:Deal.php


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