1. Go to this page and download the library: Download openstatspec/php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
openstatspec / php example snippets
use OpenStatSpec\Spss\GuardedImportSpssEngine;
use OpenStatSpec\Spss\SpssAdapter;
$pdo = new PDO('pgsql:host=localhost;dbname=statistics', $user, $password);
$adapter = new SpssAdapter($pdo);
$import = $adapter->import('/data/survey.zsav', 'survey_2026');
// SpssImportResult: operationId, datasetName, caseCount, diagnostics
$export = $adapter->export('survey_2026', '/data/survey-export.sav');
// SpssExportResult: datasetName, targetPath, caseCount, diagnostics, allowLoss
$engine = new GuardedImportSpssEngine($innerEngine, $procFdPath, 'sav');
$adapter = new SpssAdapter($pdo, $engine);
$import = $adapter->import(
$engine->logicalPath(),
'survey_2026',
verifiedSourceSha256: $verifiedSourceSha256,
);
use OpenStatSpec\Frontend\Spss\Request\SpssFrontendRequest;
use OpenStatSpec\Frontend\Spss\SpssCompiler;
use OpenStatSpec\Sql\Connection;
use OpenStatSpec\Transformation\Execution\InPlaceApplyRequest;
use OpenStatSpec\Transformation\Execution\InPlaceTransformationExecutor;
$compiled = (new SpssCompiler())->compile(SpssFrontendRequest::fromArray($request));
$apply = new InPlaceApplyRequest(
plan: $compiled->plan,
inputAlias: 'parent',
datasetId: $datasetId,
sourceHash: $compiled->sourceHash,
actor: '[email protected]',
expectedBranch: $branch,
expectedHead: $head,
);
$result = (new InPlaceTransformationExecutor(new Connection($pdo)))->execute($apply);
$adapter = new SpssAdapter($pdo);
$adapter->migrateCatalog();