1. Go to this page and download the library: Download benbjurstrom/replicate-php 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/ */
benbjurstrom / replicate-php example snippets
use BenBjurstrom\Replicate\Replicate;
...
$api = new Replicate(
apiToken: $_ENV['REPLICATE_API_TOKEN'],
);
// app/Providers/AppServiceProvider.php
public function register()
{
$this->app->bind(Replicate::class, function () {
return new Replicate(
apiToken: config('services.replicate.api_token'),
);
});
}
use Saloon\Laravel\Saloon; // composer ixture('getPrediction'),
]);
$id = 'yfv4cakjzvh2lexxv7o5qzymqy';
// The initial request will check if a fixture called "getPrediction"
// exists. Because it doesn't exist yet, the real request will be
// sent and the response will be recorded to tests/Fixtures/Saloon/getPrediction.json.
$data = app(Replicate::class)->predictions()->get($id);
// However, the next time the request is made, the fixture will
// exist, and Saloon will not make the request again.
$data = app(Replicate::class)->predictions()->get($id);