v-technologies/transformist 问题修复 & 功能扩展

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

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

v-technologies/transformist

Composer 安装命令:

composer require v-technologies/transformist

包简介

File conversion library

README 文档

README

Transformist is a PHP file conversion library. It provides a high level API to convert files into different formats painlessly.

It is also designed to be easily extended, just by adding custom converters.

Example

Here is what you could do to convert every word documents to PDF files in a directory:

<?php

$Transformist = new Transformist( );
$Transformist->setup(
	'/path/to/directory',
	'application/msword',
	'application/pdf'
);

if ( $Transformist->run( )) {
	// You're good to go !
}

?>

You can use the setup( ) method in different ways to convert multiple documents in one pass:

<?php

// Output directory

$Transformist->setup(
	array( '/path/to/input/directory' => '/path/to/output/directory' ),
	'application/msword',
	'application/pdf'
);


// Conversion of a particular file

$Transformist->setup(
	'/path/to/directory',
	'file.doc',
	'application/pdf'
);


// All files matching a pattern

$Transformist->setup(
	'/path/to/directory',
	'*.doc',
	'application/pdf'
);


// Multiple conversions

$Transformist->setup(
	'/path/to/directory',
	array(
		'*.doc'     => 'application/pdf',
		'image/jpg' => 'image/png'
	)
);

?>

Available conversions

Before going any further, you may want to know about the conversions that Transformist can handle. There's a method for that:

<?php

$conversions = $Transformist->availableConversions( );

?>

This method returns an array of all possible conversions. Each of its key represents an input type, and points to an array of output types.

Typically, it looks like this:

<?php

array(
	'image/jpeg' => array(
		'image/png'
	),
	'image/png' => array(
		'image/tiff'
	)
);

?>

Here you can convert JPG images to PNG, and PNG images to TIFF.

Test

Transformist provides a way to check all converters for validity. Some could be runnable without further configuration, while others could rely on external librairies that must be installed for the converter to work.

<?php

$results = $Transformist->testConverters( );

// Or statically:

$results = Transformist::testConverters( );

?>

$results now looks like this:

<?php

array(
	'Transformist_Converter_Office_Pdf' => true,
	'Transformist_Converter_Office_Png' => 'An external library is missing!',
	'Transformist_Converter_Office_Tiff' => true
);

?>

You should run this function only once when configuring your system or troubleshooting errors, as some converters could do some heavy computation to test their environment.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2014-04-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固