openwse / ipfs-api
IPFS API 的最小实现
v0.1.5
2021-09-08 10:15 UTC
Requires
- php: ^7.4
- ext-json: *
- guzzlehttp/guzzle: ^7.3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.18
- php-parallel-lint/php-parallel-lint: ^1.3
- phpmd/phpmd: ^2.9
- phpstan/phpstan: ^0.12.83
- phpunit/phpunit: ^9.5.4
- vlucas/phpdotenv: ^5.3
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');
代码风格检查
运行 PHPMD,PHPStan,和 PHP-CS-Fixer
composer lint
测试
composer tests
待办事项
- 完成异步/流请求
- 实现以下端点
- P2P
- Pubsub (带有名称/pubsub/{cancel,state,subs})
- 缺失的测试
- 块 > put
- 文件存储
- Dht
许可
MIT 许可证 (MIT)。请参阅许可文件以获取更多信息。