fliq/ipfs-laravel 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fliq/ipfs-laravel

最新稳定版本:v0.1.0

Composer 安装命令:

composer require fliq/ipfs-laravel

包简介

:package_description

README 文档

README

Latest Version on Packagist Total Downloads Build Status StyleCI

Interact with IPFS in Laravel.

Installation

Via Composer

composer require fliq/ipfs-laravel

Usage

Basic usage

$cid = Ipfs::add('Hello, IPFS')->first()['Hash'];

Ipfs::get($cid); // Hello, IPFS

Configuration

To publish your config run:

php artisan vendor:publish --tag=ipfs.config

Adding Files

You can flexibly add new files to IPFS using the add() method. You can add files from a string, a resource or an array, arrays will be json encoded. Use array keys to specify files names.

The second argument is an array of options more information on the IPFS documentation. The wrap-with-directoryoption will create an extra CID for the directory.

$resource = fopen('path/to/file.mp3');

$results = Ipfs::add([
    'hello.txt' => 'Hello, IPFS!', 
    'file.mp3' => $resource,
    'meta.json' => [
        'name' => 'Hello',
        'properties' => [...],
    ],
], ['wrap-with-directory' => true]);

$cid = $results->last()['Hash'];

Ipfs::get("{$cid}/hello.txt"); // Hello, IPFS!

Retrieving files

You can retrieve files using the cat(), get(), and json() methods.

  • cat()
  • get()
    • returns a string
  • json()
    • returns a json decoded array
$stream = Ipfs::cat($cid);

$str = Ipfs::get($cid);

$array = Ipfs::json($cid);

Asynchronous requests

Use the async() method to make asynchronous requests.

Async requests return Promises

Ipfs::async()->add($file)->then(function(array $results) {
    $results[0]; // do something
});

// or do multiple requests.
$ipfs = Ipfs::async();

$promises = [
    $ipfs->get($cid1),
    $ipfs->get($cid2),
];

$results = GuzzleHttp\Promise\Utils::unwrap($promises);

Testing

$ composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email author@email.com instead of using the issue tracker.

Credits

License

MIT. Please see the license file for more information.

统计信息

  • 总下载量: 15
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-08-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固