fuegas/boilerplate-slim 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fuegas/boilerplate-slim

最新稳定版本:0.1.4

Composer 安装命令:

composer require fuegas/boilerplate-slim

包简介

Boilerplate for Slim applications

README 文档

README

Environment

You can get the environment the application is running in using the Environment class. The default environment variable that is requested is SLIM_ENV. If you want to use a different variable you can specify it when requesting the environment value:

Environment::env() // Returns SLIM_ENV value or default (null)
Environment::env('MY_ENV') // Returns MY_ENV value or default (null)
Environment::env('MY_ENV', 'production') // Returns MY_ENV value or default ('production')

Logger

The boilerplate has Monolog as a dependency. It can be injected into Slim during instantiation.

By default the logger will be injected with the following values:

array(
  'name' => 'SlimMonoLogger',
  'handlers' => array(
    new \Monolog\Handler\StreamHandler('./logs/'.date('y-m-d').'.log'),
  ),
  'processors' => array(),
)

If you want to use stdout as logger, use the following instance call:

Log::getInstance([
  'name' => 'YourLogger',
  'handlers' => [ new \Monolog\Handler\StreamHandler('php://stdout') ]
]);

For other logging capabilities, please take a look at: https://github.com/Seldaek/monolog

If you want to inject the logger into Slim yourself see the following example:

$app = new \Slim\Slim(array(
  'log.writer' => new Ssllii\Helpers\Log(array(
    'name' => 'SlimMonoLogger',
    'handlers' => array(
      new \Monolog\Handler\StreamHandler('./logs/'.date('Y-m-d').'.log'),
    ),
    'processors' => array(
      function ($record) {
        $record['extra']['dummy'] = 'Hello world!';
        return $record;
      },
    ),
  ))
));

统计信息

  • 总下载量: 33
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2015-09-16