Archive
Archive gives Quantum a small wrapper for building and extracting .phar and .zip files.
Use it when you want one package-level API for simple archive tasks such as bundling files for download, packaging generated exports, or unpacking an archive into a target directory.
What it provides
ArchiveFactoryfor resolving a PHAR or ZIP archive wrapperArchiveas the package-level entry point- two built-in adapters:
pharandzip - file add, string add, extract, count, and delete operations
Quick example
use Quantum\Archive\Factories\ArchiveFactory;
use Quantum\Archive\Enums\ArchiveType;
$archive = ArchiveFactory::get(ArchiveType::ZIP);
$archive->setName(storage_dir() . '/exports/reports.zip');
$archive->addFile(storage_dir() . '/reports/january.csv', 'january.csv');
$archive->addFromString('meta.txt', 'Generated by Quantum');
$archive->extractTo(storage_dir() . '/tmp/reports');
Before you use it
Call setName() before any archive operation. Both adapters fail fast when the archive path was not set.
ArchiveFactory::get() reuses one Archive instance per adapter type through DI-backed caching. If you ask for ArchiveType::ZIP twice, you get the same wrapper object back.
That means archive name and adapter state are shared for that type inside the current process.
Adapter choices
pharis the default when you callArchiveFactory::get()with no typezipuses PHP'sZipArchive- unsupported adapter names throw immediately during factory resolution
Operational constraints
- source files passed to
addFile()must already exist or the package throws - extraction returns
bool, so failed extracts are not always raised as exceptions - some adapter-specific behavior differs, especially around partial extraction and archive cleanup