icicleio/filesystem 问题修复 & 功能扩展

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

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

icicleio/filesystem

最新稳定版本:v0.1.0

Composer 安装命令:

composer require icicleio/filesystem

包简介

Asynchronous filesystem component for Icicle.

README 文档

README

Asynchronous filesystem access that is always non-blocking, no extensions required.

This library is a component for Icicle, providing asynchronous filesystem functions and abstracting files as asynchronous streams. Like other Icicle components, this library uses Coroutines built from Awaitables and Generators to make writing asynchronous code more like writing synchronous code.

Build Status Coverage Status Semantic Version MIT License @icicleio on Twitter

Documentation and Support

Requirements
  • PHP 5.5+ for v0.1.x branch (current stable) and v1.x branch (mirrors current stable)
  • PHP 7 for v2.0 branch (under development) supporting generator delegation and return expressions
Installation

The recommended way to install is with the Composer package manager. (See the Composer installation guide for information on installing and using Composer.)

Run the following command to use this library in your project:

composer require icicleio/filesystem

You can also manually edit composer.json to add this library as a project requirement.

// composer.json
{
    "require": {
        "icicleio/filesystem": "^0.1"
    }
}
Suggested
  • eio extension: Uses libeio to provide asynchronous file access (v1.2.6+ required).

Example

#!/usr/bin/env php
<?php

require __DIR__ . '/vendor/autoload.php';

use Icicle\Coroutine;
use Icicle\File;
use Icicle\Loop;

Coroutine\create(function () {
    $path = __DIR__ . '/test.txt';

    // Create and open the file for reading and writing.
    $file = (yield File\open($path, 'w+'));

    try {
        // Write data to file.
        $written = (yield $file->write('testing'));
        
        printf("Wrote %d bytes to file.\n", $written);
        
        // Seek to beginning of file.
        yield $file->seek(0);
        
        // Read data from file.
        $data = (yield $file->read());
    } finally {
        $file->close();
    }
    
    printf("Read data from file: %s\n", $data);
    
    // Remove file.
    yield File\unlink($path);
})->done();

Loop\run();

统计信息

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

GitHub 信息

  • Stars: 39
  • Watchers: 5
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-21