bcncommerce/stream-wrapper
Laravel package providing a custom PHP stream wrapper to transparently read/write resources via non-standard URIs. Useful for integrating external storage or services behind fopen/file_get_contents with a familiar filesystem-like API.
Storage facade) with custom logic.Storage system (e.g., Filesystem, Cloud) already handles most use cases, this package could supplement:
Storage facade if used for filesystem operations.fopen() calls), but requires custom setup.Storage facade or Illuminate\Filesystem\Filesystem?
StreamHandler or Symfony’s StreamWrapper?league/flysystem for filesystem abstractions, or custom StreamContext handlers.PHP/Laravel Compatibility:
fopen(), file_get_contents()).Storage or Flysystem).Dependencies:
Storage is already intercepting streams.fopen(), file_get_contents()).phpunit.xml or tests/CreatesApplication to mock streams.
// Example: Mocking a stream in tests
StreamWrapper::register('custom', CustomStreamWrapper::class);
// app/Providers/AppServiceProvider.php
public function boot()
{
StreamWrapper::register('myapp', MyCustomWrapper::class);
}
fopen() calls with wrapper-aware methods.StreamHandler (for filesystem streams).StreamWrapper (for custom logic).stream_context_create()).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Package breaks on PHP 8.x | Integration fails | Test in isolation; have a fallback. |
| Custom wrapper leaks resources | Memory leaks, crashes | Implement close() and destroy() in wrapper. |
| Stream corruption | Data loss or silent failures | Validate data integrity post-stream. |
Laravel Storage conflicts |
Filesystem operations fail | Avoid overlapping wrapper prefixes. |
stream_wrapper_register()).Storage system.How can I help you explore Laravel packages today?