brstoker/pe-version-reader 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

brstoker/pe-version-reader

Composer 安装命令:

composer require brstoker/pe-version-reader

包简介

Extract version info from Windows PE files (.exe, .dll, .sys) and archives (.zip, .tar.gz) on any OS. No WinAPI required.

README 文档

README

A cross-platform Laravel package for extracting version information from Windows PE files (.exe, .dll, .sys) and archives (.zip, .tar.gz, .rar, .7z). Works on Linux, macOS, and Windows without WinAPI.

Requirements

  • PHP 8.1+
  • Laravel 10, 11, or 12
  • ext-zip
  • ext-phar

Optional (for archive formats)

Format Requirement
.zip ext-zip (included in PHP by default)
.tar.gz ext-phar (included in PHP by default)
.rar unrar binary
.7z 7z / 7za binary

Installing binaries

Linux (Debian/Ubuntu)

apt install unrar p7zip-full

macOS

brew install rar p7zip

Windows

Download and install WinRAR and 7-Zip. Make sure their directories are added to PATH, or the package will attempt to find them at their default installation paths automatically.

Installation

composer require vendor/pe-version-reader

Laravel will auto-discover the service provider via package auto-discovery.

If auto-discovery is disabled, register the provider manually in bootstrap/providers.php:

Brstoker\PeVersionReader\PeVersionReaderServiceProvider::class,

Usage

Basic — auto-detect file type

use Brstoker\PeVersionReader\PeVersionReader;

$reader = app(PeVersionReader::class);

$info = $reader->read('/path/to/filename.zip');
$info = $reader->read('/path/to/filename.exe');
$info = $reader->read('/path/to/library.dll');
$info = $reader->read('/path/to/driver.sys');

Explicit methods

// PE file directly
$info = $reader->readExe('/path/to/filename.exe');

// Archive — looks for a PE file matching the archive name in the archive root
$info = $reader->readZip('/path/to/filename.zip');

Working with the result

$info = $reader->read('/path/to/filename.zip');

if ($info === null) {
    // PE file with matching name was not found inside the archive
}

// Version strings
echo $info->fileVersion;      // "1.0.39.0"
echo $info->productVersion;   // "1.0.39"

// Version parts
echo $info->fileMajor;   // 1
echo $info->fileMinor;   // 0
echo $info->fileBuild;   // 39
echo $info->filePatch;   // 0

echo $info->productMajor;  // 1
echo $info->productMinor;  // 0
echo $info->productBuild;  // 39
echo $info->productPatch;  // 0

// Metadata
echo $info->companyName;      // "Acme Corp"
echo $info->productName;      // "filename"
echo $info->fileDescription;  // "filename updater"
echo $info->originalFilename; // "filename.exe"
echo $info->internalName;     // "filename"
echo $info->legalCopyright;   // "Copyright (C) 2026"
echo $info->comments;         // null

// Full array
$info->toArray();

toArray() returns:

[
    'file_version'    => '1.0.39.0',
    'product_version' => '1.0.39',

    'file_version_parts' => [
        'major' => 1,
        'minor' => 0,
        'build' => 39,
        'patch' => 0,
    ],

    'product_version_parts' => [
        'major' => 1,
        'minor' => 0,
        'build' => 39,
        'patch' => 0,
    ],

    'company_name'      => 'Acme Corp',
    'product_name'      => 'filename',
    'file_description'  => 'filename updater',
    'original_filename' => 'filename.exe',
    'internal_name'     => 'filename',
    'legal_copyright'   => 'Copyright (C) 2026',
    'comments'          => null,
]

How it works

PE files (.exe, .dll, .sys)

The package reads the binary file directly and locates the VS_VERSION_INFO resource embedded in the PE format. Version numbers are extracted from the VS_FIXEDFILEINFO structure, and string fields (company name, product name, etc.) are parsed from the StringFileInfo block. No WinAPI calls are made — the parser works entirely in pure PHP on any OS.

Archives (.zip, .tar.gz)

The package looks for a PE file in the root of the archive whose name (without extension) matches the archive name. For example, filename.zip must contain filename.exe, filename.dll, or filename.sys at the root level. Matching is case-insensitive. Once found, the file is extracted to a temporary directory, parsed, and the temp directory is cleaned up automatically.

Archives (.rar, .7z)

Same name-matching logic applies. Extraction is handled by shelling out to unrar (for .rar) or 7z / 7za (for .7z). The package auto-detects the binary location, including default installation paths on Windows (C:\Program Files\WinRAR\, C:\Program Files\7-Zip\).

Exception When
InvalidArgumentException Unsupported file extension passed to read()
FileNotFoundException File does not exist at the given path
RuntimeException Archive cannot be opened or extraction failed
UnsupportedFormatException Required binary not found (unrar, 7z)

Supported formats summary

Format Driver External dependency
.exe .dll .sys Pure PHP PE parser None
.zip ext-zip None
.tar.gz ext-phar None
.rar unrar shell unrar binary
.7z 7z shell 7z / 7za binary

License

MIT

brstoker/pe-version-reader 适用场景与选型建议

brstoker/pe-version-reader 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 31 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「version」 「windows」 「laravel」 「exe」 「pe」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 brstoker/pe-version-reader 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 brstoker/pe-version-reader 我们能提供哪些服务?
定制开发 / 二次开发

基于 brstoker/pe-version-reader 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 33
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-31