openwse/ipfs-api

IPFS API 的最小实现

v0.1.5 2021-09-08 10:15 UTC

This package is auto-updated.

Last update: 2024-09-06 13:27:30 UTC


README

安装

您可以通过 composer 安装此包

composer require openwse/ipfs-api

使用方法

$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');

代码风格检查

运行 PHPMDPHPStan,和 PHP-CS-Fixer

composer lint

测试

composer tests

待办事项

  • 完成异步/流请求
  • 实现以下端点
    • P2P
    • Pubsub (带有名称/pubsub/{cancel,state,subs})
  • 缺失的测试
    • 块 > put
    • 文件存储
    • Dht

许可

MIT 许可证 (MIT)。请参阅许可文件以获取更多信息。