PhpConcept

Developers Tools

  • Increase font size
  • Default font size
  • Decrease font size
Home PclZip User Guide

PclZip User Guide - Customizing PclZip

Print PDF

Customizing PclZip

PclZip can be customized by configuring static constants. It is recommended that you do not change these parameters, unless this is really necessary and that you understand exactly what you are doing.
Moreover when you update PclZip to a new release you will have to manually reconfigure these parameters.

The customizable values are :

PCLZIP_READ_BLOCK_SIZE
PCLZIP_TEMPORARY_DIR
PCLZIP_SEPARATOR
PCLZIP_TEMPORARY_FILE_RATIO
PCLZIP_ERROR_EXTERNAL

PCLZIP_READ_BLOCK_SIZE

This value is the size of the data block that will be read or wirte while accessing a file. It can be interesting to change this value if you know the optimized value of file access associated with your system.
The default value is 2048.

PCLZIP_TEMPORARY_DIR

When compressing or extracting files, PclZip might use temporary files. These files are created then destroyed by PclZip. By default these temporary files are created in the current working folder. This can be a problem in some situation (for example if the folder is read-only).
This customizable value allow for the definition of a static temporary folder that will be used for this working file access. The temporary folder must be read/write accessible and must exist (PclZip will not create it if missing). It is recommended to use a absolute path definition from the filesystem (and avoid relative path from web root or include folders).
The folder path MUST finish by '/'.
Exemple
define('PCLZIP_TEMPORARY_DIR''/usr/www/temp/');
include_once(
'pclzip.lib.php');

PCLZIP_SEPARATOR

In version 1.x of PclZip, the separator for file list is a space (which is not a very smart choice, specifically for windows paths !). A better separator should be a comma (,). This constant gives you the abilty to change that. However notice that changing this value, may have impact on existing scripts, using space separated filenames.
Recommended value for compatibility with older versions :
define( 'PCLZIP_SEPARATOR', ' ' );
Default value for smart separation of filenames :
define( 'PCLZIP_SEPARATOR', ' ' );
define('PCLZIP_SEPARATOR'';');
include_once(
'pclzip.lib.php');

PCLZIP_TEMPORARY_FILE_RATIO

Optional threshold ratio for use of temporary files

Pclzip sense the size of the file to add/extract and decide to use or not temporary file. The algorythm is looking for memory_limit of PHP and apply a ratio.
  threshold = memory_limit * ratio.
Recommended values are under 0.5. Default 0.47.

PCLZIP_ERROR_EXTERNAL

Deprecated parameter used in the past to enable an external error library not anymore distributed with PclZip.

 

Error Handling [Table Of Content] Troubleshooting PclZip

 

Last Updated on Saturday, 19 December 2009 12:28