PHP code example of soiposervices / comfydeploy

1. Go to this page and download the library: Download soiposervices/comfydeploy library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

soiposervices / comfydeploy example snippets


use SoipoServices\ComfyDeploy\ComfyDeploy;
...

$api = new ComfyDeploy(
    apiToken: $_ENV['COMFY_DEPLOY_API_TOKEN'],
);

$deployment_id = 'e4a14vs9-q40j-4ee2-1375-778b2je3221c';
$input = [
    'model' => 'prompt',
    'postive_prompt' => 'a photo of an astronaut riding a horse on mars',
    'seed' => null,
];

$data = $api->workflows()->run($deployment_id, $input);
$data->run_id; // 257b65b8-ac23-49be-8aca-53d2dd8556c6

// config/services.php
'comfy_deploy' => [
    'api_token' => env('COMFY_DEPLOY_API_TOKEN'),
],

// app/Providers/AppServiceProvider.php
public function register()
{
    $this->app->bind(ComfyDeploy::class, function () {
        return new ComfyDeploy(
            apiToken: config('services.comfy_deploy.api_token'),
        );
    });
}

$data = app(ComfyDeploy::class)->workflows()->get($run_id);

use Saloon\Laravel\Saloon; // composer ixture('getWorkflow'),
]);

$run_id = '257b65b8-ac23-49be-8aca-53d2dd8556c6';

// The initial request will check if a fixture called "getWorkflow" 
// exists. Because it doesn't exist yet, the real request will be
// sent and the response will be recorded to tests/Fixtures/Saloon/getWorkflow.json.
$data = app(ComfyDeploy::class)->workflows()->get($run_id);

// However, the next time the request is made, the fixture will 
// exist, and Saloon will not make the request again.
$data = app(ComfyDeploy::class)->workflows()->get($run_id);

$api->workflows()->withWebhook('https://www.example.com/webhook')->run($deployment_id, $input);
$data->run_id; // 257b65b8-ac23-49be-8aca-53d2dd8556c6

use SoipoServices\ComfyDeploy\Data\GetWorkflowData;
...
$run_id = '257b65b8-ac23-49be-8aca-53d2dd8556c6'
/* @var GetWorkflowData $data */
$data = $api->workflows()->get($run_id);
$data->id;

use SoipoServices\ComfyDeploy\Data\RunWorkflowData
...
$deployment_id = 'e4a14vs9-q40j-4ee2-1375-778b2je3221c';
$input = [
    'postive_prompt' => 'a photo of an astronaut riding a horse on mars',
];

/* @var RunWorkflowData $data */
$data = $api->workflows()
    ->withWebhook('https://www.example.com/webhook') // optional
    ->run($deployment_id, $input);
$data->run_id; // 257b65b8-ac23-49be-8aca-53d2dd8556c6