Repository navigation
Internals Installer Package Extractor
Framework Internals · Subsystem overview · Developer guide
Source: awt_src/classes/installer/package/Extractor.php · Snapshot 8411f4287706.
Installation validates archives and manifests, moves files, persists metadata, copies data into storage, invokes an optional hook and emits an event. These operations do not form one atomic transaction.
use installer\interfaces\package\IExtractor;
use RuntimeException;
use vfs\transient\interfaces\ITransientStorageEntry;
use ZipArchive;class Extractor implements IExtractorDeclarations below preserve visibility, type, default and modifiers exactly. A typed property without an initializer remains uninitialized until its constructor or another method assigns it. Mutable fields belong to this instance unless marked static; readonly fields can be initialized once. Constructor-promoted properties are also listed below.
| Member | Declaration | Purpose or source contract |
|---|---|---|
| Constructor-promoted | private ZipArchive $zip |
Initialized from the constructor argument; default expression is evaluated when the argument is omitted. |
| Constructor-promoted | private ITransientStorageEntry $target |
Initialized from the constructor argument; default expression is evaluated when the argument is omitted. |
| Constructor-promoted | private string $destination |
Initialized from the constructor argument; default expression is evaluated when the argument is omitted. |
| Method | Signature |
|---|---|
| __construct | public function __construct( private ZipArchive $zip, private ITransientStorageEntry $target, private string $destination ) |
| extract | public function extract(): void |
| getZip | public function getZip(): ZipArchive |
| getTarget | public function getTarget(): ITransientStorageEntry |
| getDestination | public function getDestination(): string |
| setTarget | public function setTarget(ITransientStorageEntry $target): void |
| setDestination | public function setDestination(string $destination): void |
| zipVerify | public function zipVerify(): void |
| makeDestination | private function makeDestination(): void |
public function __construct(
private ZipArchive $zip,
private ITransientStorageEntry $target,
private string $destination
);| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$zip |
private ZipArchive $zip |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$target |
private ITransientStorageEntry $target |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$destination |
private string $destination |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
Concrete no-op/default hook: this method performs no work. Override it where the lifecycle or extension contract calls for behavior.
public function extract(): void@throws \RuntimeException
Explicit exceptions: RuntimeException. The guards in the implementation below show when each is raised; exceptions from collaborators also propagate unless caught.
Implementation, validation guards and interaction order
/**
* @inheritDoc
* @throws \RuntimeException
*/
public function extract(): void
{
$this->destination .= hash("md5", $this->target->getName());
$this->makeDestination();
$result = $this->zip->open($this->target->getPath());
if ($result !== true) throw new RuntimeException("Could not open package archive (ZIP error {$result}).");
try {
$this->zipVerify();
if (!$this->zip->extractTo($this->destination)) throw new RuntimeException('Could not extract package archive.');
} finally {
$this->zip->close();
}
}public function getZip(): ZipArchiveReturn expressions (including local callbacks): $this->zip.
Implementation, validation guards and interaction order
/**
* @inheritDoc
*/
public function getZip(): ZipArchive
{
return $this->zip;
}public function getTarget(): ITransientStorageEntryReturn expressions (including local callbacks): $this->target.
Implementation, validation guards and interaction order
/**
* @inheritDoc
*/
public function getTarget(): ITransientStorageEntry
{
return $this->target;
}public function getDestination(): stringReturn expressions (including local callbacks): $this->destination.
Implementation, validation guards and interaction order
/**
* @inheritDoc
*/
public function getDestination(): string
{
return $this->destination;
}public function setTarget(ITransientStorageEntry $target): void| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$target |
ITransientStorageEntry $target |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
State writes: $this->target.
Implementation, validation guards and interaction order
/**
* @inheritDoc
*/
public function setTarget(ITransientStorageEntry $target): void
{
$this->target = $target;
}public function setDestination(string $destination): void| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$destination |
string $destination |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
State writes: $this->destination.
Implementation, validation guards and interaction order
/**
* @inheritDoc
*/
public function setDestination(string $destination): void
{
$this->destination = $destination;
}public function zipVerify(): voidExplicit exceptions: RuntimeException. The guards in the implementation below show when each is raised; exceptions from collaborators also propagate unless caught.
Implementation, validation guards and interaction order
/**
* @inheritDoc
*/
public function zipVerify(): void
{
if($this->zip->status !== ZipArchive::ER_OK){
throw new RuntimeException("There was an error extracting the package. ZIP status: {$this->zip->status}");
}
}private function makeDestination(): voidExplicit exceptions: RuntimeException. The guards in the implementation below show when each is raised; exceptions from collaborators also propagate unless caught.
External effects include mkdir.
Implementation, validation guards and interaction order
//Helpers
private function makeDestination(): void
{
if(!is_dir($this->destination) && !mkdir($concurrentDirectory = $this->destination, 0755, true) && !is_dir($concurrentDirectory)) {
throw new RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
}
}AWT Framework Wiki · Home · Installation Guide · Developer Guide · Framework Internals
Philosophy · Architecture · Known discrepancies · Verification
Installation Guide
Developer Guide
- Learning sequence
- First package
- Package structure
- Lifecycle
- Runtimes
- Events and objects
- Routing and controllers
- Views and resources
- Database and models
- Storage and caching
- Configuration and CLI
- Responses and errors
- Extension points
Framework Internals
- Architecture
- Bootstrap
- Packages
- Runtime
- Events and context
- Objects
- HTTP routing and controllers
- Rendering
- Blade integration
- Database
- Models
- Storage and caching
- Settings
- CLI
- Identity and sessions
- Responses
- Errors
- Complete source inventory
Documentation notes