ericjank / aliyun-tablestore-sdk-php
PHP版本的阿里云Tablestore SDK,兼容hyperf框架协程模式
Requires
- php: >=5.5
- google/protobuf: ^3.5
- guzzlehttp/guzzle: ^5.3.1|^6.2.1
- guzzlehttp/promises: ~1.0
- guzzlehttp/psr7: ^1.4.1
Requires (Dev)
- phpunit/phpunit: ^4.8.35|^5.4.3
- satooshi/php-coveralls: ~1.0
Suggests
- ext-curl: To send requests using cURL
- ext-openssl: Allows working with HTTPS
This package is auto-updated.
Last update: 2024-09-08 15:30:23 UTC
README
说明
(兼容hyperf协程、连接池版本)
阿里云OTS SDK for PHP,用于通过PHP访问阿里云OTS服务。
适用于PHP 5.5及以上版本,包括7.0、7.1、7.2。只支持64位的PHP系统。推荐使用PHP7,以获得最佳性能。
当前仅支持Linux,其他系统需要用户自行修改代码以支持。
使用步骤
-
请确认您的PHP版本为5.5或更高。您可以通过运行php --version来查看当前使用的PHP版本。
-
设置PHP时区,在php.ini(要了解您正在使用的php.ini文件的位置,请执行命令php --ini)中添加一行:
date.timezone = Asia/Shanghai (请根据您当地的时区进行设置)
-
设置PHP内存使用限制为512M或更高。同样是在php.ini中修改:
memory_limit = 512M
-
执行安装命令
composer require ericjank/aliyun-tablestore-sdk-php:dev-master
- 发布配置文件
php bin/hyperf.php vendor:publish ericjank/aliyun-tablestore-sdk-php
此命令会生成config/autoload/tablestore.php配置文件
-
根据您的实际情况配置.env
-
实例化客户端
$client = new \Aliyun\OTS\OTSClient() ;
编程文档
我们提供了HTML格式的文档,请在浏览器中打开这些文档。
-
文档主页:docs/index.html
-
SDK的调用入口 OTSClient:docs/classes/Aliyun.OTS.OTSClient.html
该文档中有丰富的代码示例,详细说明了每个API的使用方法。
-
客户端配置:docs/classes/Aliyun.OTS.OTSClientConfig.html
-
重试策略:docs/namespaces/Aliyun.OTS.Retry.html
-
服务端返回的错误:docs/classes/Aliyun.OTS.OTSServerException.html
-
客户端返回的错误:docs/classes/Aliyun.OTS.OTSClientException.html
运行Sample程序
- 修改examples/ExampleConfig.php,添加配置信息
- 执行cd examples/
- 选择需要的示例运行,例如php PKAutoIncrment.php,表格列自增功能的示例。
运行单元测试
-
执行composer install下载依赖的库
-
如果是php 7.2,还需要执行composer require --dev phpunit/phpunit "^5.7.11",升级phpunit版本以支持。
-
设置环境变量
export SDK_TEST_ACCESS_KEY_ID=access-key-id export SDK_TEST_ACCESS_KEY_SECRET=access-key-secret export SDK_TEST_END_POINT=endpoint export SDK_TEST_INSTANCE_NAME=instance-name
-
执行php vendor/bin/phpunit
贡献代码
- 我们非常欢迎为TableStore PHP SDK以及其他阿里云SDK贡献代码