In
your PHP development, it’s quite likely that you will encounter
files in different formats—CSV data, password files, XML-encoded content, and
different forms of binary data. Often, your PHP script will need to interact
with these files, reading and writing data to and from them.

You
can obtain assistance in dealing with these different file formats by turning
to the PHP Extension and Application Repository (PEAR). PEAR
has a number of packages that can significantly simplify working with and
manipulating different file formats. These packages provide well-tested
routines to read and write custom formats, and using them can save you a fair
amount of time. You can’t beat the price either—they’re free!

This
document lists 10 PEAR packages of specific interest to developers who need to
work with custom file formats.

Note: You can
install PEAR packages directly from the Web, by following the instructions
provided at the PEAR Web site.

Table A

Package Name

Description

Link

Archive_Tar

This package lets you
dynamically manipulate TAR archives. It allows you to package multiple files
into a single TAR file, list the contents of a TAR archive, and selectively
extract from (or import into) a TAR file.

Use this package when you need to dynamically
create or extract files from TAR archives.

Archive_Tar

XML_RSS

This package is
designed to parse RSS documents. It extracts information from an RSS feed as
PHP data structures, which can be processed and formatted for display.

Use this package when you need to read RSS channel
information and metadata.

XML_RSS

MP3_ID

This package provides
routines to view and edit the metadata information stored in MP3 file
headers. It supports editing common fields like artist, title, track length,
genre and duration.

Use this package to dynamically alter MP3 file
metadata.

MP3_ID

File_Bittorrent

This package lets you
encode and decode Bittorrent data streams, create new torrents, and
extract information from existing torrents.

Use this package to when you need create, encode
and decode Bittorrent streams.

File_Bittorrent

File_CSV

This package provides
routines to efficiently deal with comma-separated data. It allows you to
transform comma-separated values into PHP data structures for easier access,
as well as write new CSV fields to a file.

Use this package when you need to work with files
containing comma-delimited data fields.

File_CSV

File_Passwd

This package provides
an object-oriented interface to manipulate different types of password files.
It includes methods to add, edit and delete users and passwords, validate
passwords, and generate passwords. It supports /etc/passwd passwords, SMB passwords,
CVS passwords and Apache .htaccess and digest
passwords.

Use this package when you need to manipulate a
variety of password files, to verify passwords, and to easily add/edit/delete
user accounts.

File_Passwd

File_Fstab

This package lets you
manipulate UNIX fstab
(file system table) files. It allows you to view, add, edit and delete
partition and mount point information using object methods.

Use this package if you need a safe way to edit the
system’s startup mount devices.

File_Fstab

File_PDF

This package lets you
dynamically generate PDF files, without requiring any PDF support in your PHP
build.

Use this package when you need to generate PDF
files on the fly. This is especially useful when your PHP build doesn’t
include PDF support and you cannot easily recompile it.

File_PDF

File_DNS

This package is
designed specifically to read and write DNS “zone files”. These
zone files hold information relevant to the DNS servers for the domain.

Use this package when you need to manipulate DNS
server entries.

File_DNS

Contact_Vcard_Parse

This package reads
and converts contact information stored in vCard format to PHP data structures.

Use this package when you need to convert vCard
address and contact information into other formats (for example, XML or SQL).

Contact_Vcard_Parse