skylab/studio 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

skylab/studio

最新稳定版本:0.0.2

Composer 安装命令:

composer require skylab/studio

包简介

studio.skylabtech.ai PHP client

README 文档

README

studio.skylabtech.ai

Installation

composer require skylab/studio

Example usage

Ensure that autoload is configured properly in composer.json

{
  "autoload": {
    "psr-4": {
      "Skylab\\Studio\\": "src/"
    }
  }
}
require './vendor/autoload.php';
use Skylab\Studio\SkylabStudio;

$api = new SkylabStudio('your-api-key');

// CREATE PROFILE
$profilePayload = [
  'name' => 'profile name',
  'enable_crop' => false,
  'enable_retouch' => true
];

$profile = $api->createProfile($profilePayload);

// CREATE JOB
$jobPayload = [
  'name' => 'job name',
  'profile_id' => $profile['id']
];

$job = $api->createJob($jobPayload);

// UPLOAD JOB PHOTO(S)
$filePath = '/path/to/photo';
$api->uploadJobPhoto($filePath, $job['id']);

// QUEUE JOB
$payload = [ 'callback_url' => 'YOUR_CALLBACK_ENDPOINT' ];
$api->queueJob($job['id'], $payload);

// NOTE: Once the job is queued, it will transition to processed and then completed
// We will send a response to the specified callback_url with the output photo download urls

Jobs

List all Jobs

List the last 30 jobs.

$api->listJobs();

Create a Job

$payload = [
  'name' => 'your unique job name',
  'profile_id' => 123
]

$api->createJob($payload);

For all payload options, consult the API documentation.

Get a Job

$api->getJob($jobId);

Get Job by Name

$api->getJobByName($name);

Update a Job

$payload = [
  'name' => 'your updated job name',
  'profile_id' => 123
]

$api->updateJob($jobId, $payload);

For all payload options, consult the API documentation.

Queue Job

$payload = [ 'callback_url' => 'YOUR_CALLBACK_ENDPOINT' ]

$api->queueJob($jobId, $payload);

Jobs in Front

$api->getJobsInFront($jobId);

Delete a Job

$api->deleteJob($jobId);

Cancel a Job

$api->cancelJob($jobId);

Profiles

List all Profiles

$api->listProfiles();

Create a Profile

$api->createProfile([
  'name' => 'My Profile'
]);

For all payload options, consult the API documentation.

Get a Profile

$api->getProfile($profileId);

Update profile

$payload = [
  'name' => 'My updated profile name',
];

$api->updateProfile($profileId, $payload);

For all payload options, consult the API documentation.

Photos

Upload Job Photo

This function handles validating a photo, creating a photo object and uploading it to your job/profile's s3 bucket. If the bucket upload process fails, it retries 3 times and if failures persist, the photo object is deleted.

$api->uploadJobPhoto($photoPath, $jobId);

Returns: { photo: { photoObject }, uploadResponse: bucketUploadResponseStatus }

If upload fails, the photo object is deleted for you. If upload succeeds and you later decide you no longer want to include that image, use delete_photo to remove it.

Get a Photo

$api->getPhoto($photoId);

Delete a Photo

$api->deletePhoto($photoId);

Troubleshooting

General Troubleshooting

  • Enable debug mode
  • Capture the response data and check your logs — often this will have the exact error

Enable Debug Mode

Debug mode prints out the underlying request information as well as the data payload that gets sent to Skylab. You will most likely find this information in your logs. To enable it, simply put true as a parameter when instantiating the API object.

$api = new SkylabStudio("your-api-key", true);

Response Ranges

SkylabTech's API typically sends responses back in these ranges:

  • 2xx – Successful Request
  • 4xx – Failed Request (Client error)
  • 5xx – Failed Request (Server error)

If you're receiving an error in the 400 response range follow these steps:

  • Double check the data and ID's getting passed to Skylab
  • Ensure your API key is correct
  • Log and check the body of the response

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2024-04-08