zero-to-prod / stream-context
A wrapper for stream_context_create()
Fund package maintenance!
zero-to-prod
v71.2.3
2024-10-18 13:44 UTC
Requires
- php: ^7.1
- ext-openssl: *
- zero-to-prod/data-model: ^71.0
- zero-to-prod/dynamic-setter: ^71.0
- zero-to-prod/transformable: ^71.0
Requires (Dev)
- phpunit/phpunit: ^7.0
README
A wrapper for the stream_context_create()
method.
It provides classes that define all the options for this method.
Installation
To install this package run composer install:
composer require zerotoprod/stream-context
Usage
use Zerotoprod\StreamContext\StreamContext; use Zerotoprod\StreamContext\DataModels\Options; use Zerotoprod\StreamContext\DataModels\Http; $client = stream_socket_client( 'ssl://neverssl.com:443', $error_code, $error_message, 30, STREAM_CLIENT_CONNECT, StreamContext::create([ Options::http => [ Http::method => 'GET', Http::header => "Accept-language: en\r\n"."Cookie: foo=bar", Http::proxy => 'proxy' ], ['options'] ])->context ); fclose($client);
Supported Protocols
- HTTP: Customize request methods, headers, user-agent, and more.
- FTP: Manage file transfers with options like overwrite, resume position, and proxy.
- SSL: Configure SSL/TLS options including peer verification, certificates, and more.
- Phar: Set options like compression and metadata for Phar archives.
- Zip: Handle encrypted Zip files with password options.
- Zlib: Control compression levels for zlib streams.