PHPackages                             moonlydays/php-vpk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. moonlydays/php-vpk

ActiveLibrary[File &amp; Storage](/categories/file-storage)

moonlydays/php-vpk
==================

Valve's VPK archive implementation for PHP.

1.1.3(2mo ago)235MITPHPPHP ^8.2

Since Jul 22Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/MoonlyDays/php-vpk)[ Packagist](https://packagist.org/packages/moonlydays/php-vpk)[ Docs](https://github.com/MoonlyDays/php-vpk)[ RSS](/packages/moonlydays-php-vpk/feed)WikiDiscussions main Synced yesterday

READMEChangelog (5)Dependencies (3)Versions (7)Used By (0)

php-vpk
=======

[](#php-vpk)

A pure-PHP library for reading Valve's [VPK](https://developer.valvesoftware.com/wiki/VPK) archive format — the package format used by Source engine games such as Team Fortress 2, Counter-Strike: Source, and Half-Life 2.

Supports VPK v1 and v2 directory files. No native extensions required beyond `ext-mbstring`.

Installation
------------

[](#installation)

```
composer require moonlydays/php-vpk
```

Requires PHP 8.2 or newer.

Usage
-----

[](#usage)

```
use MoonlyDays\VPK\VpkArchive;

$archive = new VpkArchive('/path/to/tf2_misc_dir.vpk');

// List every file in the archive
foreach ($archive->files() as $path) {
    echo $path, PHP_EOL;
}

// Extract a single file
$archive->extractFileTo('materials/console/background01.vmt', __DIR__ . '/out');

// Or extract everything
$archive->extractTo(__DIR__ . '/out');

$archive->close();
```

### How VPK files are laid out

[](#how-vpk-files-are-laid-out)

A VPK archive is split across multiple files on disk:

- `_dir.vpk` — holds the header and the directory tree
- `_000.vpk`, `_001.vpk`, ... — hold the actual file payloads

You always open the `_dir.vpk` file. The sibling chunk files must live in the same directory; the library opens them lazily as needed during extraction and caches the handles until `close()` is called.

API
---

[](#api)

### `MoonlyDays\VPK\VpkArchive`

[](#moonlydaysvpkvpkarchive)

MethodDescription`__construct(string $filePath)`Open a `_dir.vpk`. Throws `VpkException` if the header signature is invalid.`files(): array`Return the list of every file path contained in the archive.`extractFileTo(string $path, string $targetDir): bool`Extract a single file by its in-archive path. Returns `false` if the path is unknown or the backing chunk file is missing. Existing files on disk are left untouched.`extractTo(string $targetDir): void`Extract every file in the archive into `$targetDir`, preserving the directory structure.`close(): void`Close all cached chunk-file handles.### `MoonlyDays\VPK\VpkException`

[](#moonlydaysvpkvpkexception)

Thrown by the `VpkArchive` constructor when the input file does not have a valid VPK header signature.

Development
-----------

[](#development)

```
composer install
composer test    # run the Pest 3 suite
composer lint    # run Laravel Pint
```

The test suite generates all VPK fixtures at runtime, so no binary test data is committed to the repository.

License
-------

[](#license)

Released under the MIT License.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance84

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~125 days

Recently: every ~157 days

Total

6

Last Release

84d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/87d541941e03738e9760a7ea35c5ce19347b67e29eb81a216e872b4158b6dc61?d=identicon)[MoonlyDays](/maintainers/MoonlyDays)

---

Top Contributors

[![MoonlyDays](https://avatars.githubusercontent.com/u/32462579?v=4)](https://github.com/MoonlyDays "MoonlyDays (11 commits)")

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/moonlydays-php-vpk/health.svg)

```
[![Health](https://phpackages.com/badges/moonlydays-php-vpk/health.svg)](https://phpackages.com/packages/moonlydays-php-vpk)
```

###  Alternatives

[ericnorris/amazon-s3-php

A lightweight and fast S3 client for PHP.

2147.0k](/packages/ericnorris-amazon-s3-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
