定制 phasync/http-streamwrapper 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

phasync/http-streamwrapper

最新稳定版本:0.0.1-rc1

Composer 安装命令:

composer require phasync/http-streamwrapper

包简介

An HTTP stream wrapper that makes http:// and https:// requests in PHP asynchronous.

README 文档

README

phasync/http-streamwrapper is a PHP package that makes all HTTP and HTTPS requests asynchronous transparently, when used within a phasync coroutine. This package allows you to perform HTTP operations like fetching data from URLs asynchronously, improving the efficiency of your I/O-bound tasks such as web requests.

Installation

You can install the package via Composer. There is no configuration needed as it automatically configures itself to be enabled inside coroutines and disables itself outside of coroutines.

composer require phasync/http-streamwrapper

Usage

When installing this package, async http:// and https:// I/O is automatically enabled inside phasync coroutines. It does not interfere with I/O outside of coroutines.

Example

Here's an example of how to use phasync/http-streamwrapper within the phasync coroutine framework:

<?php

require 'vendor/autoload.php';

// Example usage within phasync coroutine framework
phasync::run(function() {
    phasync::go(function() {
        $data = file_get_contents("http://example.com");
        // Handle the data
        echo "Data from http://example.com: " . $data . PHP_EOL;
    });

    phasync::go(function() {
        $data = file_get_contents("https://example.com");
        // Handle the data
        echo "Data from https://example.com: " . $data . PHP_EOL;
    });
});

In this example, two URLs are fetched asynchronously using file_get_contents within phasync coroutines. The custom stream wrapper ensures that these HTTP operations are non-blocking and efficient.

License

This package is open-source and licensed under the MIT License.

Contributing

Contributions are welcome! Please submit pull requests or open issues for any bugs or feature requests.

Contact

For any questions or inquiries, please open an issue on the GitHub repository.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-05-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固