PHP client for Replicate
Build | GitHub pages | Stable | License |
---|---|---|---|
- PHP >= 7.1
- PHP extensions:
- JSON (
ext-php
)
- JSON (
- Guzzle HTTP (
guzzlehttp/guzzle
)
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
Include autoload in your project:
require __DIR__ . '/vendor/autoload.php';
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());
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