platformsh/client
Composer 安装命令:
composer require platformsh/client
包简介
Platform.sh API client
README 文档
README
This is a PHP library for accessing the Platform.sh API.
We recommend you use the Platform.sh CLI (which uses this library) for most purposes.
Versions
- The
3.xbranch (major version 3) requires PHP 8.2 and above. - The
2.xbranch (major version 2) requires PHP 7.2.5 and above. This branch is no longer maintained. - The
1.xbranch (any version < 2) supports PHP 5.5.9 and above, and uses Guzzle 5. Old PHP versions are supported by the Platform.sh CLI, which is why this branch is still maintained.
Install
composer require platformsh/client
Usage
Example:
use Platformsh\Client\Connection\Connector; use Platformsh\Client\PlatformClient; // Set up configuration. $connector = new Connector([ 'api_url' => 'https://api.platform.sh', 'accounts' => 'https://api.platform.sh/', 'centralized_permissions_enabled' => true, ]); // Initialize the client. $client = new PlatformClient(); // Set the API token to use. // // N.B. you must keep your API token(s) safe! $client->getConnector()->setApiToken($myToken, 'exchange'); // Get a project. $project = $client->getProject('my_project_id'); if ($project) { // Get the default (production) environment. $environment = $project->getEnvironment($project->default_branch); // Create a new environment. $result = $environment->runOperation('branch', body: ['name' => 'sprint-1', 'title' => 'Sprint 1']); // Wait for the operation to complete. $activities = $result->getActivities(); while (count($activities) > 0) { foreach ($activities as $key => $activity) { if ($activity->isComplete() || $activity->state === \Platformsh\Client\Model\Activity::STATE_CANCELLED) { unset($activities[$key]); } else { echo "Waiting for the activity: {$activity->getDescription()}\n"; $activity->wait(function () { echo '.'; }); echo "\n"; } } } // Get the new branch. $sprint1 = $project->getEnvironment('sprint-1'); }
Creating a project:
use \Platformsh\Client\Model\Subscription\SubscriptionOptions; $subscription = $client->createSubscription(SubscriptionOptions::fromArray([ 'project_region' => 'uk-1.platform.sh', 'project_title' => 'My project', 'plan' => 'development', 'default_branch' => 'main', ])); echo "Created subscription $subscription->id, waiting for it to activate...\n"; $subscription->wait(); $project = $subscription->getProject(); echo "The project is now active: $project->id\n"; echo "Git URI: " . $project->getGitUrl() . "\n";
platformsh/client 适用场景与选型建议
platformsh/client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 344.98k 次下载、GitHub Stars 达 28, 最近一次更新时间为 2015 年 02 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 platformsh/client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 platformsh/client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 344.98k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 29
- 点击次数: 9
- 依赖项目数: 3
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-24