1.3.0 2017-08-23 11:51 UTC



Dont know what ipfs is? the future of filesystems :) read here for more information!

Build Status Scrutinizer Code Quality Code Coverage


as always, use composer!

$ composer require ipfs/php-client

choosing the HTTP Adapter

If you plan to use the REST Interface of the ipfs-daemon you should choose a http-implementation. We use php-http for abstraction.

See here for a list of available implementations!

if you only want to speak with a local ipfs-daemon you should use the IPFS\\Drivers\\Cli adapter.


as we use Annotations you should register the AnnotationLoader

$loader = require __DIR__.'/../vendor/autoload.php';

use Doctrine\Common\Annotations\AnnotationRegistry;

AnnotationRegistry::registerLoader(array($loader, "loadClass"));


we ship with different adapters for communicating with the daemon.


if you are using an ipfs binary that is not available in you $PATH variable, provide an ENV var for it:

$ export IPFS_BINARY=/my/location/to/ipfs

make sure you set IPFS_PATH in you ENV if you are not using ~/.ipfs as location.

to use this Driver from the commandline simply provide the option:

$ bin/php-ipfs version --driver=IPFS\\Driver\\Cli


if you are talking to a remote daemon provide an ENV var for it:

$ export IPFS_API=http://somehost:5001/api/v0

to use this Driver from the commandline simply provide the option (or leave it away since its the default):

$ bin/php-ipfs version --driver=IPFS\\Driver\\Http
$ bin/php-ipfs version


this Driver is intended for programmatically usage:

$driver = $container[IPFS\Driver\Cli::class];
//$driver = $container[IPFS\Driver\Http::class];
$client = new IPFS\Client($driver);

$reponse = $client->execute((new \IPFS\Api\Basics())->version());



All Api-Endpoints are autogenerated from the official ipfs docs and are regulary checked for changes.

To rebuild the Apis yourself, simply run composer rebuild-api

The following endpoints exists:

Available commands:
  add                       Add a file or directory to ipfs.
  cat                       Show IPFS object data.
  commands                  List all available commands.
  dns                       Resolve DNS links.
  get                       Download IPFS objects.
  help                      Displays help for a command
  id                        Show ipfs node id info.
  list                      Lists commands
  ls                        List directory contents for Unix filesystem objects.
  mount                     Mounts IPFS to the filesystem (read-only).
  ping                      Send echo request packets to IPFS hosts.
  rebuild                   rebuild api classes by parsing the official api doc
  resolve                   Resolve the value of names to IPFS.
  version                   Show ipfs version information.
  bitswap:ledger            Show the current ledger for a peer.
  bitswap:stat              Show some diagnostic information on the bitswap agent.
  bitswap:unwant            Remove a given block from your wantlist.
  bitswap:wantlist          Show blocks currently on the wantlist.
  block:get                 Get a raw IPFS block.
  block:put                 Store input as an IPFS block.
  block:rm                  Remove IPFS block(s).
  block:stat                Print information of a raw IPFS block.
  bootstrap:add:default     Add default peers to the bootstrap list.
  bootstrap:list            Show peers in the bootstrap list.
  bootstrap:rm:all          Remove all peers from the bootstrap list.
  config:edit               Open the config file for editing in $EDITOR.
  config:replace            Replace the config with .
  config:show               Output config file contents.
  dht:findpeer              Query the DHT for all of the multiaddresses associated with a Peer ID.
  dht:findprovs             Find peers in the DHT that can provide a specific value, given a key.
  dht:get                   Given a key, query the DHT for its best value.
  dht:provide               Announce to the network that you are providing given values.
  dht:put                   Write a key/value pair to the DHT.
  dht:query                 Find the closest Peer IDs to a given Peer ID by querying the DHT.
  diag:cmds:clear           Clear inactive requests from the log.
  diag:cmds:set-time        Set how long to keep inactive requests in the log.
  diag:net                  Generate a network diagnostics report.
  diag:sys                  Print system diagnostic information.
  file:ls                   List directory contents for Unix filesystem objects.
  files:cp                  Copy files into mfs.
  files:flush               Flush a given path’s data to disk.
  files:ls                  List directories in the local mutable namespace.
  files:mkdir               Make directories.
  files:mv                  Move files.
  files:read                Read a file in a given mfs.
  files:rm                  Remove a file.
  files:stat                Display file status.
  files:write               Write to a mutable file in a given filesystem.
  log:level                 Change the logging level.
  log:ls                    List the logging subsystems.
  log:tail                  Read the event log.
  name:publish              Publish IPNS names.
  name:resolve              Resolve IPNS names.
  object:data               Output the raw bytes of an IPFS object.
  object:diff               Display the diff between two ipfs objects.
  object:get                Get and serialize the DAG node named by .
  object:links              Output the links pointed to by the specified object.
  object:new                Create a new object from an ipfs template.
  object:patch:add-link     Add a link to a given object.
  object:patch:append-data  Append data to the data segment of a dag node.
  object:patch:rm-link      Remove a link from an object.
  object:patch:set-data     Set the data field of an IPFS object.
  object:put                Store input as a DAG object, print its key.
  object:stat               Get stats for the DAG node named by .
  pin:add                   Pin objects to local storage.
  pin:ls                    List objects pinned to local storage.
  pin:rm                    Remove pinned objects from local storage.
  refs:local                List all local references.
  repo:fsck                 Remove repo lockfiles.
  repo:gc                   Perform a garbage collection sweep on the repo.
  repo:stat                 Get stats for the currently used repo.
  repo:verify               Verify all blocks in repo are not corrupted.
  repo:version              Show the repo version.
  stats:bitswap             Show some diagnostic information on the bitswap agent.
  stats:bw                  Print ipfs bandwidth information.
  stats:repo                Get stats for the currently used repo.
  swarm:addrs:local         List local addresses.
  swarm:connect             Open connection to a given address.
  swarm:disconnect          Close connection to a given address.
  swarm:filters:add         Add an address filter.
  swarm:filters:rm          Remove an address filter.
  swarm:peers               List peers with open connections.
  tar:add                   Import a tar file into ipfs.
  tar:cat                   Export a tar file from IPFS.
  tour:list                 Show a list of IPFS Tour topics.
  tour:next                 Show the next IPFS Tour topic.
  tour:restart              Restart the IPFS Tour.


simply use the commandline interface

$ bin/php-ipfs
$ bin/php-ipfs add ./composer.lock --wrap-with-directory --driver=IPFS\\Driver\\Cli
$ bin/php-ipfs add ./composer.lock --wrap-with-directory


to build a phar file simply run

we assume you have https://box-project.github.io/box2/ installed!

$ composer build


this library is well covered with phpspec

$ composer test