ecourty/ipfs-php
最新稳定版本:1.4.0
Composer 安装命令:
composer require ecourty/ipfs-php
包简介
A lightweight IPFS interaction library for PHP
README 文档
README
IPFS-PHP provides a simple way to interact with an IPFS Node using PHP.
The changelog for this project can be found here.
Installation
composer require ecourty/ipfs-php
Usage
The following example shows how to add a file to IPFS and retrieve its content later.
<?php use IPFS\Client\IPFSClient; // Three different ways to instantiate the client $client = new IPFSClient(url: 'http://localhost:5001'); // If nothing is passed, the default values are used (localhost and 5001) // $client = new IPFSClient(); // $client = new IPFSClient(host: 'localhost', port: 5001); // Add a file $file = $client->addFile('file.txt'); echo 'File uploaded: ' . $file->hash; // File uploaded: QmWGeRAEgtsHW3ec7U4qW2CyVy7eA2mFRVbk1nb24jFyks // ... // Get the file content $fileContent = $client->cat($file->hash); // ... // Downloads the complete file $file = $client->get($file->hash); // ... // Download the file as a tar archive (compression can be specified with the compression parameters) $archive = $client->get($file->hash, archive: true); file_put_contents('archive.tar', $archive); // ...
More code examples can be found under the examples directory.
© Edouard Courty 2025
统计信息
- 总下载量: 756
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-12