Download the PHP package indy2kro/php-iso without Composer
On this page you can find all versions of the php package indy2kro/php-iso. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download indy2kro/php-iso
More information about indy2kro/php-iso
Files in indy2kro/php-iso
Package php-iso
Short Description PHP ISO file Library. A library for reading ISO files using PHP.
License GPL-2.0-or-later
Homepage https://github.com/indy2kro/php-iso
Informations about the package php-iso
PHP ISO Library
PHP Library used to read metadata and extract information from ISO files based on php-iso-file
This library follows the ISO 9660 / ECMA-119 standard.
See SECURITY.md to report a vulnerability (the library parses untrusted images).
Basic concepts
IsoFile- main ISO file object, contains one more descriptorsDescriptor- descriptor object which can have one of the following types defined inTypeclass:BOOT_RECORD_DESC:BootobjectPRIMARY_VOLUME_DESC:PrimaryVolumeobjectSUPPLEMENTARY_VOLUME_DESC:SupplementaryVolumeobjectPARTITION_VOLUME_DESC:PartitionobjectTERMINATOR_DESC:Terminatorobject- upon initialization of the
IsoFileobject, the descriptors will be populated automatically
- Volume descriptors contain path table inside which can be loaded using
loadTablePathTableRecord- object which contains the record information for a file/directory
- Each class contains various properties which can be used to interact with them, they are
public readonly: the parsed structures are immutable and fully initialised when the object is created, and dates areCarbonImmutable FileSystem- what can be browsed: an ISO 9660 / JolietVolumeor theUdfFileSystem. Both offerwalk,listDirectory,find,search,readFile,openStreamandcopyEntryTo, and describe files withIsoEntryobjects
Features
- Reads the ISO 9660 volume descriptors (primary, supplementary, enhanced (ISO 9660:1999), boot, partition, terminator)
- Joliet (Unicode long file names) detection and support (
IsoFile::getSupplementaryVolume()); the ISO 9660:1999 enhanced volume is available withIsoFile::getEnhancedVolume() - El Torito boot catalog parsing (
Boot::loadCatalog()), including catalogs spanning several sectors, the boot image size (BootEntry::getImageSize()) and image extraction (BootCatalog::extractImage()) - Directory tree walking with
Volume::walk()(no need to process the path table manually) and lookups by path withfind()(only the directories on the path are read),listDirectory()andsearch() - Safe extraction with
Extractor(names coming from the ISO are validated, nothing can be written outside of the destination); modification times are restored, and the optionspreserveMode(apply the Rock Ridge permissions) andcontinueOnError(collect the problems withgetErrors()instead of aborting) are available - Both-endian (M and L) path tables, directories spanning multiple sectors, multi-extent files (reported once)
- UDF file system reading (
IsoFile::getUdfFileSystem()): plain and metadata partitions (UDF 2.50, e.g. Blu-ray images), symbolic links, owner and permissions. UDF only images (and UDF bridge images carrying a stub ISO 9660 tree) are browsable throughIsoFile::getFileSystem()like ISO 9660 ones - Rock Ridge: POSIX long names, mode, owner, symbolic links, precise timestamps (
TF), device numbers (PN), continuation areas and relocated directories (Volume::walk(),IsoEntry::$rockRidge); symbolic links are never created on extraction IsoEntryexposesuid,gid,modeandsymlinkTarget(Rock Ridge and UDF)- Reading file content:
find(),search(),readFile()andopenStream(); streams are seekable and read the image on demand (Util\EntryStream), nothing is copied to a temporary file - Images coming from non-seekable streams (standard input, pipes) with
IsoFile::fromStream()
Known limitations
- UDF: only 2048 bytes blocks are read; sparable and virtual (VAT) partitions are reported as unsupported. For metadata partitions the mirror and bitmap files are ignored
Installation
This class can easily be installed via Composer:
composer require indy2kro/php-iso
Requires PHP 8.3 or newer and nesbot/carbon.
CLI tool
This tool also provides a CLI tool that can be used to view information about ISO files - bin\isotool:
Sample usage (isotool -f fixtures/1mb.iso --files, without --files the lists of files are left out):
Other examples:
Usage
Walking the files of an ISO (Joliet names are used when present):
getFileSystem() or getPreferredVolume()? getPreferredVolume() returns the Joliet volume (else the primary one), it is only about ISO 9660 and returns null for UDF only images. getFileSystem() returns a FileSystem that also covers UDF: the preferred volume, or the UDF file system for UDF only images and for bridge images (e.g. Windows install media) whose ISO 9660 tree is only a stub. Prefer getFileSystem() unless you need a Volume (path table, descriptor fields).
Looking up and reading files (find() matches the exact name first, then ignoring the case):
Entries carry the Rock Ridge / UDF attributes:
Reading an image from a pipe or standard input (copied to a temporary file, removed when the object is destroyed; at most IsoFile::MAX_STREAM_BYTES by default):
Extracting everything (names are untrusted input, the extractor refuses names that could escape the destination):
Reading the El Torito boot catalog and extracting the boot image:
Errors and exceptions
Every failure caused by the image or by an invalid argument is a PhpIso\Exception (PhpIso\Descriptor\Exception extends it), nothing else should escape for a damaged image; catching PhpIso\Exception is enough:
new IsoFile($path): the file does not exist, is not a regular file or cannot be opened, the volume descriptors are truncated or invalid, or there are more thanIsoFile::MAX_DESCRIPTORSof themIsoFile::fromStream(): the stream cannot be read, is bigger than the limit, or is not an image (same as above)IsoFile::getUdfFileSystem()andgetFileSystem(): the UDF structures are present but unsupported or corrupt (getFileSystem()falls back to the ISO 9660 tree when it has one)FileSystem::readFile(),openStream(),copyEntryTo(): the entry is a directory, the file is bigger than$maxSize, or its data lies outside of the imageExtractor::extract(): unsafe names (path traversal, Windows reserved names...), failed writes (collected ingetErrors()instead whencontinueOnErroris set)Volume::loadTable(),Boot::loadCatalog(),BootCatalog::extractImage(): corrupt tables or catalogs
Limits
The image is untrusted input, so sizes taken from it are bounded:
IsoFile::MAX_READ_LENGTH(64 MiB): the largest single read, so a directory, path table orreadFile()result cannot be biggerIsoFile::MAX_STREAM_BYTES(4 GiB): the largest stream accepted byIsoFile::fromStream()unless another limit is givenIsoFile::MAX_DESCRIPTORS(64): the maximum number of volume descriptors readwalk($isoFile, $maxDepth = 64): directories nested deeper are not listed A listing can therefore be incomplete (too deep or oversized directories, corrupt directory records, unreadable UDF entries). Pass aPhpIso\WalkWarningscollector towalk(),listDirectory(),find(),search()orExtractor::extract()to find out (new WalkWarnings(strict: true)throws aPhpIso\Exceptionat the first problem instead):
Low level access to the descriptors and the path table: