1. Go to this page and download the library: Download fliq/ipfs 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/ */
fliq / ipfs example snippets
use Fliq\Ipfs\Ipfs;
$ipfs = new Ipfs('localhost', '8080', 'http', 'gateway');
$data = $ipfs->cat('QmSgvgwxZGaBLqkGyWemEDqikCqU52XxsYLKtdy3vGZ8uq')->wait(); // spaceship-launch.jpg
use Fliq\Ipfs\Ipfs;
$ipfs = new Ipfs('localhost', '5001', 'http', 'api');
$result = $ipfs->add('Hello, IPFS')->wait();
$cid = $result[0]['Hash']; // content identifier
$data = $ipfs->cat('Qm...')
->then(fn($stream) => $stream->getContents())
->then(fn($str) => json_decode($str, 1))
->wait();
// is the same as.
$data = $ipfs->get('Qm...')
->then(fn($str) => json_decode($str, 1))
->wait();
// is the same as
$data = $ipfs->json('Qm...')->wait();