A client library for the IPFS API.
This is a complete from-the-ground-up rewrite of cloutier/php-ipfs-api.
This library requires PHP 7.3 and the curl and json extensions.
$ composer require rannmann/php-ipfs-api
$ composer install
use rannmann\PhpIpfsApi\IPFS;
// connect to ipfs daemon API server
$ipfs = new IPFS("localhost", 8080, 5001); // leaving out the arguments will default to these values
Adds content to IPFS.
Usage
$hash = $ipfs->add("Hello world");
Adds content to IPFS from a filename (helper method)
Usage
$hash = $ipfs->addFromPath("myFile.txt");
Adds content ot IPFS from a web URL (helper method)
Usage
$hash = $ipfs->addFromUrl('https://mysite.com/img.png');
Retrieves the contents of a single hash.
Usage
$ipfs->get($hash);
Gets the node structure of a hash.
Usage
$nodes = $ipfs->ls($hash);
foreach ($nodes as $node) {
echo $node['Hash'];
echo $node['Size'];
echo $node['Name'];
}
Returns object size.
Usage
$size = $ipfs->size($hash);
Pin or unpin a hash.
Usage
$ipfs->pinAdd($hash);
$ipfs->pinRm($hash);
Get information about your ipfs node.
Usage
print_r($ipfs->id());
The MIT License (MIT)
Copyright (c) 2019 Jake Forrester Copyright (c) 2016 S3r3nity Technologies Copyright (c) 2015-2016 Vincent Cloutier
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.