vipertecpro / game3d-save
Save slots for game3d games: versioned, checksummed, migrated and recovered, written safely on the phone.
Requires
- php: ^8.5
- vipertecpro/game3d: ^2.1
Requires (Dev)
- pestphp/pest: ^3.0|^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-28 20:03:25 UTC
README
An add-on for game3d, a paid plugin for NativePHP Mobile sold at https://vipertecpro.com/products/game3d-engine (Android only). This add-on is free and MIT, and needs game3d to run. It is an independent project, not made or endorsed by NativePHP.
Save slots for games made with game3d: versioned, checksummed, migrated as the game changes, and recovered when a slot is damaged. PHP only, MIT.
use Vipertecpro\Game3dSave\Save; Save::schema(2, 'main')->migrate(1, fn (array $d) => ['coins' => $d['gold']], 'main'); Save::slot('main')->write(['level' => 3, 'coins' => 120]); $loaded = Save::slot('main')->load(); // ->status, ->data, ->savedAt Save::autosave('main', fn () => $this->state(), minSeconds: 2); Save::touch('main'); // at most once every 2 s Save::flush(); // what waits, now
In a scene, ->checkpoint('main') saves from the engine: in a command list
(a finish line's contact rule) it needs no round trip of its own.
Install
This add-on needs a game3d licence. From your dashboard at vipertecpro.com, add the game3d Composer repository and key (the two composer config commands shown there), then:
composer require vipertecpro/game3d-save
- Where:
storage/app/game3d-save, the app's own files on the phone. - Safe writes: a temporary file renamed into place; the slot before it is kept as
<slot>.bak. - Damage: a slot cut short or edited (its checksum fails) loads its backup:
Recovered. With both damaged it isCorrupt, kept as<slot>.corrupt. - Versions: each slot has its own
schema()andmigrate()steps (mainby default), run on load, so a game's migrations never touch another slot (the economy's). A slot from a newer game is read (Newer) and never written over, nor its backup. - Names: slot names are letters, digits,
-and_. - Not a lock: the checksum finds damage; it does not stop players editing their own saves.
Testing
The tests need game3d ^2.1, which is not public, so they run where a licensed copy is
installed: add the game3d repository as in Install, then run composer install and
vendor/bin/pest.