autoloader for custom stream wrappers
まだ誰も着手していません。
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.1k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
Would it be possible to add an autoloader/callback function if a call is made to a function using a stream wrapper protocol that is not yet defined?
Currently, if you access a stream protocol not registered, a warning is logged 'Unable to find the wrapper "abc" - did you forget to enable it when you configured PHP?'.
In the below example, since abc hasn't yet been registered with stream_wrapper_register(), the new function stream_wrapper_autoload() would be called where abc would be registered and allow the file_get_contents() call to complete.
<?php
stream_wrapper_autoload(function($protocol)
{
switch ($protocol)
{
case 'abc':
stream_wrapper_register('abc', 'abc');
break;
}
});
$a = file_get_contents('abc://file.txt');
?>
I am using the AWS S3 stream wrapper (https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/s3-stream-wrapper.html). Using this custom stream wrapper currently requires me either to:
- register the stream wrapper on every request even if it won't be used on the given request
- or register it before any call that would use it (file_get_contents, fopen, copy, etc).
- or add a wrapper function around file_get_contents and the other file functions to check first if the stream wrapper is registered by calling stream_get_wrappers().
Having an autoload function would allow me to register the stream wrapper only when it's needed.
Thank you for your help.
Ryan
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、未解決のストリームプロトコルを file_get_contents()、fopen()、copy() を通じて追跡し、stream_wrapper_register() と stream_get_wrappers() が現在どのように登録を処理しているかを確認します。コールバックの動作と失敗した検索との相互作用を定義し、次にコールバックによって登録されたラッパーによって元のファイル操作を完了できることを検証します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php
- 領域
- backend
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100