定制 flavioheleno/interim 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

flavioheleno/interim

最新稳定版本:v0.1.0

Composer 安装命令:

composer require flavioheleno/interim

包简介

An open_basedir aware wrapper for tmpfile() and sys_get_temp_dir()

README 文档

README

Interim is a simple wrapper around PHP's tmpfile() and sys_get_temp_dir() that takes into account open basedir restriction.

Installation

To use Interim, simple run:

composer require flavioheleno/interim

Usage

When open_basedir is disabled, Interim behaves exactly the same way as sys_get_temp_dir():

// before
var_dump(sys_get_temp_dir());
// string(4) "/tmp"

// after
var_dump(Interim\Temporary::getDirectory());
// string(4) "/tmp"

// -or-
var_dump(Interim\Temporary::getDirectory('tmp'));
// string(4) "/tmp"

// -or-
var_dump(Interim\Temporary::getDirectory('/var/tmp'));
// string(4) "/tmp"

When open_basedir is enabled, Interim will check if temporary dir is in the open_basedir list, if not, it will return an alternative.

ini_set('open_basedir', '/var/www/html:/var/tmp');

// before (if you try to use "/tmp", an "open_basedir restriction in effect" warning will be raised)
var_dump(sys_get_temp_dir());
// string(4) "/tmp"

// after
var_dump(Interim\Temporary::getDirectory());
// string(4) "/var/www/html"

// -or-
var_dump(Interim\Temporary::getDirectory('tmp'));
// string(4) "/var/www/html/tmp"

// -or-
var_dump(Interim\Temporary::getDirectory('/var/tmp'));
// string(4) "/var/tmp"

License

This library is licensed under the MIT License.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-03-27