定制 gidato/temporary-path 二次开发

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

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

gidato/temporary-path

Composer 安装命令:

composer require gidato/temporary-path

包简介

Creates a new temporary path object within a given temporary directory base

README 文档

README

Creates new temporary file or directory Gidato/Filesystem/Model objects.

If directory/file is then created, it will automatically disappear when the object is destroyed via the destruct method.

This can be called manually as well via the drop() method.

To facilitate this, each file type must be mapped to an equivalent Temporary file type. Both BasicFile and JsonFile have been set up, but others can be added to the FileClassMapper - see examples below.

Installation


composer require gidato/temporary-path

Example Use

<?php

use Gidato\TemporaryPath\Temporary;
use Gidato\Filesystem\Model\Base;

$base = new Base('/filesbase');
$temporary =  new Temporary($base->directory('tmp'));

// creates a TemporaryDirectory
$directory = $temporary->directory();
$directory->create();
$directory->drop();

// creates a TemporaryBasicFile
$file = $temporary->file();

// creates a TemporaryJsonFile
$file = $temporary->file('json');

// new file types - ConfigJsonFile extends JsonFile
$base->getFileTypesHandler()->addType('config.json', ConfigJsonFile::class);

// creates a TemporaryJsonFile as mapper not set up to convert ConfigJsonFile to anything else
$file = $temporary->file('config.json');

// now set up a mapper for ConfigJsonFile
$temporary->getFileClassMapper()->addType(ConfigJsonFile::class, TemporaryConfigJsonFile::class);

// now creates a TemporaryConfigJsonFile
$file = $temporary->file('config.json');

You can also track any creations so that all can be dropped at the same time. This is primarily to catch issues where the destruction of the object does not take place when there has been an error/exception.

<?php

$code = $temporary->track();

$file = $temporary->file();
$file->create();

$$directory = $temporary->directory();
$directory->create();

// drop all temporary files and directories since code was created
$temporary->dropSice($code);

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-04-09

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固