opensourcewebsite-org/php-stellar-sdk
Composer 安装命令:
composer require opensourcewebsite-org/php-stellar-sdk
包简介
Stellar Horizon client library for the PHP language
README 文档
README
PHP Stellar SDK provides APIs to build and sign transactions, connect and query Stellar Horizon server.
This library is under active development and should be considered beta quality. Please ensure that you've tested extensively on a test network and have added sanity checks in other places in your code.
The repository is a part of the OpenSourceWebsite Organization. This project and everyone participating in it is governed by the Code of Conduct.
Getting Started
See the release notes for breaking changes.
See the getting-started directory for examples of how to use this library. Additional examples are available in the examples directory.
Please read through Stellar API Documentation and Stellar Testnet Documentation.
Contributing
Please read through our Contribution Guidelines.
Installation
The preferred way to install this extension is through composer.
Either run
composer require opensourcewebsite-org/php-stellar-sdk
or add
"opensourcewebsite-org/php-stellar-sdk": "*"
to the require section of your composer.json file.
Usage
Large Integer Support
The largest PHP integer is 64-bits when on a 64-bit platform. This is especially important to pay attention to when working with large balance transfers. The native representation of a single XLM (1 XLM) is 10000000 stroops.
Therefore, if you try to use a MAX_INT number of XLM (or a custom asset) it is
possible to overflow PHP's integer type when the value is converted to stroops and
sent to the network.
This library attempts to add checks for this scenario and also uses a BigInteger
class to work around this problem.
If your application uses large amounts of XLM or a custom asset please do extensive
testing with large values and use the StellarAmount helper class or the BigInteger
class if possible.
Floating point issues
Although not specific to Stellar or PHP, it's important to be aware of problems when doing comparisons between floating point numbers.
For example:
$oldBalance = 1.605; $newBalance = 1.61; var_dump($oldBalance + 0.005); var_dump($newBalance); if ($oldBalance + 0.005 === $newBalance) { print "Equal\n"; } else { print "Not Equal\n"; }
The above code considers the two values not to be equal even though the same value is printed out:
Output:
float(1.61)
float(1.61)
Not Equal
To work around this issue, always work with and store amounts as an integer representing stroops. Only convert back to a decimal number when you need to display a balance to the user.
The static StellarAmount::STROOP_SCALE property can be used to help with this conversion.
Tests
$ composer test
Feedback
To request a new feature, submit a bug report, give us feedback, start a design discussion or have an idea to make this code better feel free to open an issue, or create a pull request.
Please send all security issues to security@opensourcewebsite.org.
License
This project is open source and available freely under the MIT license.
opensourcewebsite-org/php-stellar-sdk 适用场景与选型建议
opensourcewebsite-org/php-stellar-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.03k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2021 年 06 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 opensourcewebsite-org/php-stellar-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 opensourcewebsite-org/php-stellar-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.03k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-06-22