1. Go to this page and download the library: Download apex/ipfs-api 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/ */
apex / ipfs-api example snippets
$client = new Ipfs\Ipfs(
new Ipfs\Drivers\HttpClient('https://ipfs-host', 5001)
);
// add a single file (and pin it)
$client->add('/path/to/the/file', true);
// add a file from content
$client->add([
['/desired-path-on-ipfs/filename.txt', null, 'my text content', 'text/plain']
]);
// add a nested structure
$client->add([
['/path/to/local/file', '/path/on/ipfs'],
'my-custom-dir',
['/path/to/local/file', '/my-custom-dir/filename'],
]);
// list all files
$client->files()->ls();
// get the version
$client->version();
// publish
$client->key()->gen('mykeyname');
$client->name()->publish('/path/hash', '48h', 'mykeyname');
// some other examples...
$client->cat('/path/hash');
$client->config()->set('key', 'value');
$client->pin()->add('/path/hash');
$client->pin()->verify();
$client->stats()->bw();
$client->key()->rm('mykeyname');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.