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


PHP Slim::app方法代码示例

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


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

示例1: init

 /**
  * Initialize Slim
  *
  * This instantiates the Slim application, sets a default NotFound
  * handler, and sets the View class used to render templates. If the
  * view class parameter is null, a default View will be created.
  *
  * @param   string  $viewClass  The name of the view class Slim will use
  * @return  void
  */
 public static function init($viewClass = null)
 {
     self::$app = new Slim();
     self::notFound(array('Slim', 'defaultNotFound'));
     $view = is_null($viewClass) ? 'View' : $viewClass;
     self::view($view);
 }
开发者ID:kolanos,项目名称:Slim,代码行数:17,代码来源:Slim.php

示例2: init

 /**
  * Initialize Slim
  *
  * This instantiates the Slim application using the provided
  * application settings if available. This also:
  *
  * - Sets a default Not Found handler
  * - Sets a default Error handler
  * - Sets the view class
  *
  * Legacy Support:
  *
  * To support applications built with an older version of Slim,
  * this method's argument may also be a string (the name of a View class)
  * or an instance of a View class or subclass.
  *
  * @param   array|string|Slim_View  $viewClass   An array of settings;
  *                                               The name of a View class;
  *                                               A View class or subclass instance;
  * @return  void
  */
 public static function init( $userSettings = array() ) {
     //Legacy support
     if ( is_string($userSettings) || $userSettings instanceof Slim_View ) {
         $settings = array('view' => $userSettings);
     } else {
         $settings = (array)$userSettings;
     }
     self::$app = new Slim($settings);
     self::notFound(array('Slim', 'defaultNotFound'));
     self::error(array('Slim', 'defaultError'));
     self::view(Slim::config('view'));
     if ( Slim::config('log.enable') === true ) {
         $logger = Slim::config('log.logger');
         if ( empty($logger) ) {
             Slim_Log::setLogger(new Slim_Logger(Slim::config('log.path'), Slim::config('log.level')));
         } else {
             Slim_Log::setLogger($logger);
         }
     }
 }
开发者ID:ntdt,项目名称:Slim,代码行数:41,代码来源:Slim.php

示例3: init

 /**
  * Initialize Slim
  *
  * This instantiates the Slim application using the provided
  * application settings if available.
  *
  * Legacy Support:
  *
  * To support applications built with an older version of Slim,
  * this method's argument may also be a string (the name of a View class)
  * or an instance of a View class or subclass.
  *
  * @param   array|string|Slim_View  $viewClass   An array of settings;
  *                                               The name of a View class;
  *                                               A View class or subclass instance;
  * @return  void
  */
 public static function init($userSettings = array())
 {
     //Legacy support
     if (is_string($userSettings) || $userSettings instanceof Slim_View) {
         $settings = array('view' => $userSettings);
     } else {
         $settings = (array) $userSettings;
     }
     //Init app
     self::$app = new Slim($settings);
     //Init Not Found and Error handlers
     self::notFound(array('Slim', 'defaultNotFound'));
     self::error(array('Slim', 'defaultError'));
     //Init view
     self::view(Slim::config('view'));
     //Init logging
     if (Slim::config('log.enable') === true) {
         $logger = Slim::config('log.logger');
         if (empty($logger)) {
             Slim_Log::setLogger(new Slim_Logger(Slim::config('log.path'), Slim::config('log.level')));
         } else {
             Slim_Log::setLogger($logger);
         }
     }
     //Start session if not already started
     if (session_id() === '') {
         $sessionHandler = Slim::config('session.handler');
         if ($sessionHandler instanceof Slim_Session_Handler) {
             $sessionHandler->register();
         }
         session_start();
         if (isset($_COOKIE[session_id()])) {
             Slim::deleteCookie(session_id());
         }
         session_regenerate_id(true);
     }
     //Init flash messaging
     self::$app->flash = new Slim_Session_Flash(self::config('session.flash_key'));
     self::view()->setData('flash', self::$app->flash);
     //Determine mode
     if (isset($_ENV['SLIM_MODE'])) {
         self::$app->mode = (string) $_ENV['SLIM_MODE'];
     } else {
         $configMode = Slim::config('mode');
         self::$app->mode = $configMode ? (string) $configMode : 'development';
     }
 }
开发者ID:alanvivona,项目名称:scawTP,代码行数:64,代码来源:Slim.php


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