riverside/php-replicate

PHP client for Replicate

1.0.0 2024-09-09 17:32 UTC

This package is auto-updated.

Last update: 2024-11-09 17:50:57 UTC


README

PHP client for Replicate

Requirements

  • PHP >= 7.1
  • PHP extensions:
    • JSON (ext-php)

Dependencies

  • Guzzle HTTP (guzzlehttp/guzzle)

Installation

If Composer is not installed on your system yet, you may go ahead and install it using this command line:

$ curl -sS https://getcomposer.org/installer | php

Next, add the following require entry to the composer.json file in the root of your project.

{
    "require" : {
        "riverside/php-replicate" : "^1.0"
    }
}

Finally, use Composer to install php-replicate and its dependencies:

$ php composer.phar install 

Configuration

Include autoload in your project:

require __DIR__ . '/vendor/autoload.php';

How-to use

Create an instance of Request:

$request = new \Riverside\Replicate\Request('your token');

Create an instance of Model

$model = new \Riverside\Replicate\Model($request);

Call actual endpoint:

$response = $model->get('model owner', 'model name');

Get result:

print_r($response->getBody());

Full example:

<?php
$request = new \Riverside\Replicate\Request('your token');
$model = new \Riverside\Replicate\Model($request);
$response = $model->get('model owner', 'model name');
print_r($response->getBody());

or

<?php
use Riverside\Replicate\Request;
use Riverside\Replicate\Model;

$request = new Request('your token');
$model = new Model($request);
$response = $model->get('model owner', 'model name');
print_r($response->getBody());

Running tests

Developers clone the repository, and if needed, they can create their own phpunit.xml by copying phpunit.xml.dist and filling in their own configuration without modifying the version-controlled file.

cp phpunit.xml.dist phpunit.xml

API