Phar::convertToPhar
Phar::convertToZip
Phar
PHP Manual

# Phar::convertToTar

(No version information available, might be only in CVS)

Phar::convertToTar — Convert the phar archive to the tar file format, optionally compressing the entire archive using gzip or bzip2 compression

### Description

bool Phar::convertToTar ( int `$compression` )

> Note: This method requires the php.ini setting phar.readonly to be set to 0 in order to work for Phar objects. Otherwise, a PharException will be thrown.

This method is used to convert a phar archive in phar or zip format to the tar file format.

### Parameters

`compression`

  This can be one of Phar::GZ or Phar::BZ2. By default, no compression is applied.

### Return Values

The method returns `TRUE` on success, but it is safer to encase the call within a try/catch block and assume success if an exception is not thrown.

### Errors/Exceptions

This method throws BadMethodCallException when unable to compress, an unknown compression method has been specified, the requested archive is buffering with Phar::startBuffering() and has not concluded with Phar::stopBuffering(), an UnexpectedValueException if write support is disabled, and a PharException if any problems are encountered during the phar creation process.

### Examples

Example#1 A Phar::convertToTar() example

Using Phar::convertToTar():

`<?php
try {
$zip = new Phar('myphar.zip.phar');
$tar = $zip->convertToTar();
$phar->setStub('<?php include "phar://" . __FILE__ . "/cli.php"; __HALT_COMPILER();');
} catch (Exception $e) {
// handle the error here
}
?>`

### See Also

- Phar::convertToPhar()
- Phar::convertToZip()
- Phar::compressAllFilesGZ()
- Phar::compressAllFilesBZIP2()

Phar::convertToPhar
Phar::convertToZip
Phar
PHP Manual