flobee / spss
SPSS 是 IBM SPSS Statistics Standard 的基于 PHP 的实现。 (读写 SPSS, PSPP .sav 文件)
5.0.0
2022-02-28 13:04 UTC
Requires
- php: >=5.6
- ext-bcmath: *
- ext-mbstring: *
Requires (Dev)
- composer/composer: ^2.1.
- friendsofphp/php-cs-fixer: ^2.16
- phing/phing: *
- phpunit/phpunit: ^5.7 || ^6.4 || ^7.0 || ^9
- squizlabs/php_codesniffer: *
README
项目目前未维护。请检查 github.com/tiamo/spss
一个用于读取和写入 SPSS / PSPP .sav 数据文件的 PHP 库。
版本 4.* (有关详细信息,请参阅 升级部分)
tiamo/spss 的分支。大部分代码库相同。引入了一个更完整的测试环境,现在已存在。所以,有一天我会切换回它。
目录
要求
PHP 8.0 及以上。
- php-cli
- php-mdstring
- php-bcmath
安装
通过 composer 安装此扩展是首选方法
运行以下命令
composer require flobee/spss
将您的 composer.json
文件的依赖项部分添加以下内容 请参阅此处 或从 此处 下载。
使用
在 examples/ 文件夹中,您将找到更多示例。
读取器示例
$reader = \SPSS\Sav\Reader::fromFile('path/to/file.sav')->read();
或
$reader = \SPSS\Sav\Reader::fromString(file_get_contents('path/to/file.sav'))->read();
写入器示例
$writer = new \SPSS\Sav\Writer([
'header' => [
'prodName' => '@(#) SPSS DATA FILE test',
'layoutCode' => 2,
'compression' => 1,
'weightIndex' => 0,
'bias' => 100,
'creationDate' => '13 Feb 89',
'creationTime' => '23:58:59',
],
'variables' => [
[
'name' => 'VAR1',
'width' => 0,
'decimals' => 0
'format' => 5,
'columns' => 50,
'align' => 1,
'measure' => 1,
'data' => [
1, 2, 3
],
],
...
]
]);
...
测试/开发者
使用 shell 安装
git clone https://github.com/flobee/spss.git
cd spss/
git submodule init # once
git submodule update --recursive # upgrading (after a `git pull`)
最初或升级以获取开发依赖项
composer install
为了安装更多开发工具,您可能需要安装 phpstan/phpstan composer require -dev phpstan/phpstan
,它显示了应用程序中的许多结构问题,并且应该得到更多的关注(从 level=1 开始)。
更新现有代码
git pull
git submodule update
composer install
运行测试
VERSION 4:
Improved additions for CI systems (e.g: jenkins) where `phing` is the
prefered build tool. `composer` the prefered package manager.
# shows you the options
./phing -l
# executes the tests
./phing test
# executes the tests and create the code coverage
./phing coverage
# run all tasks (CS checks, coverage, tests, sca...)
./phing all
...
cd tests
sh ./runTests.sh
# have a look at ../docs/CodeCoverage (use a browser after execution)
sh ./runTestsCoverageCreate.sh
# playground:
php readerDemo.php | less
# or to update tmp file to check for changes:
php readerDemo.php > data/pspp.sav.printr.txt
升级到版本 3.*
更新您的 composer.json
{
...
"require": {
"flobee/spss": "3.*",
},
...
}
下一步
composer update flobee/spss
依赖错误?
如果您遇到依赖错误,您也可以升级其他 spss 依赖项。如果是这样,请尝试以下操作
composer update flobee/spss --with-dependencies
变更日志
许可
请查阅 许可文本