A PHP library for reading and writing SPSS / PSPP SAV and ZSAV data files.
Maintained by OpenStatSpec. This project continues the MIT-licensed codebase created by Vladyslav Korniienko. The stable PHP namespace remains SPSS\ for compatibility.
- PHP 8.4.1 or newer
- mbstring extension
- bcmath extension
- zlib extension
composer require openstatspec/spss-savRead a file into the v3 typed dataset model:
use SPSS\Sav\Reader;
$dataset = Reader::fromFile('/path/to/input.sav')->readDataset();
foreach ($dataset->rows() as $row) {
// Values follow the order of $dataset->variables().
}Write a typed dataset:
use SPSS\Sav\Writer;
$writer = new Writer($dataset);
$writer->save('/path/to/output.sav');
$writer->close();Numeric null cells represent SPSS system-missing values. Strings must always be strings; an empty string is an ordinary value. SPSS dates, times, and currencies remain numeric values whose presentation is described by VariableFormat.
See the v3 typed Dataset guide for creating datasets, metadata, SAV/ZSAV support, and migration from the legacy array API. The older low-level examples remain available during migration.
Please have a look in CHANGELOG
Install the locked development dependencies:
composer installThe install command activates the versioned pre-push hook in .githooks. It runs the same complete QA suite used in CI before every push. You can also run the checks directly:
composer qa
composer qa:releasecomposer qa validates and audits Composer dependencies, lints PHP syntax, checks coding style, runs Rector in dry-run mode, performs PHPStan level 6 analysis with strict rules, and executes the PHPUnit 13 tests. composer qa:release additionally enforces:
- at least 85% executable-line coverage;
- at least 74% branch coverage across the deterministic branch shards;
- Infection's mutation-testing threshold, with timeouts counted against the score and capped;
- bidirectional SAV/ZSAV interoperability with R/haven.
The release suite requires Xdebug coverage plus Rscript with the haven package. The pre-push hook runs this complete release suite. Run composer fix to apply safe Rector and coding-style fixes.
See Quality and release gates for individual commands, report locations, and the rationale for each threshold.
Licensed under the MIT license.