dev-master
9999999-dev https://github.com/nikkiii/vbspPHP Library for Valve data formats and utilities.
ISC
The Requires
by Nikki
bsp source engine vpk valve formats
Wallogit.com
2017 © Pedro Peláez
PHP Library for Valve data formats and utilities.
This is by no means stable, bla bla bla. It works for what I wrote it for, and will be updated as I need more features, or if you need more features, just submit an issue., (*1)
Install it using Composer:, (*2)
composer require nikkiii/vlib, (*3)
To open a BSP file:, (*4)
<?php
require_once 'vendor/autoload.php';
use VLib\BSP\BSPFile;
$fh = fopen('path/to/map.bsp', 'r');
$bsp = new BSPFile($fh);
// $bsp->version = format version
// $bsp->entities = entities
// $bsp->pakfile = pak file, use openArchive() to get a ZipArchive.
To open a VPK file (Uses Flysystem for universal filesystem access):, (*5)
<?php
require_once 'vendor/autoload.php';
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;
use VLib\VPK\VPKArchive;
$filesystem = new Filesystem(new Local('/path/to/dir/with/vpks'));
$vpk = new VPKArchive($filesystem, 'pak01_dir.vpk');
$entry = $vpk->get('resource/l4d360ui_english.txt');
// To get a stream:
$stream = $entry->stream();
// To automatically call stream_get_contents:
$contents = $entry->getData();
Using LangWrapper (Ideally you'd load this data from VPKArchive using KeyValues, Warning: You'll probably need to use mb_convert_encoding from UCS-2LE to UTF-8 on language files), (*6)
<?php
require_once 'vendor/autoload.php';
use VLib\KeyValues\LangWrapper;
$tokens = [
'Something' => 'Blabla'
];
$data = [
'nested' => [
'key' => '#Something'
]
];
$lang = new LangWrapper($tokens, $data);
echo $lang->get('nested.key'); // Blabla
To open a DEM file:, (*7)
<?php
require_once 'vendor/autoload.php';
use VLib\DEM\DEMFile;
$dem = new DEMFile('some_file.dem'); // Either string or resource (open file handle)
// $dem->... contains properties
PHP Library for Valve data formats and utilities.
ISC
bsp source engine vpk valve formats