https://github.com/zero-to-prod/stream-socket
A wrapper for stream_socket_client().
https://github.com/zero-to-prod/stream-socket
php stream-socket
Last synced: 5 months ago
JSON representation
A wrapper for stream_socket_client().
- Host: GitHub
- URL: https://github.com/zero-to-prod/stream-socket
- Owner: zero-to-prod
- License: mit
- Created: 2024-09-08T13:16:17.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-09-01T22:41:46.000Z (7 months ago)
- Last Synced: 2025-09-30T23:47:23.504Z (6 months ago)
- Topics: php, stream-socket
- Language: PHP
- Homepage: https://zero-to-prod.github.io/stream-socket/
- Size: 184 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# Zerotoprod\StreamSocket

[](https://github.com/zero-to-prod/stream-socket)
[](https://github.com/zero-to-prod/stream-socket/actions)
[](https://github.com/zero-to-prod/stream-socket/actions)
[](https://packagist.org/packages/zero-to-prod/stream-socket/stats)
[](https://packagist.org/packages/zero-to-prod/stream-socket)
[](https://github.com/zero-to-prod/stream-socket)
[](https://github.com/zero-to-prod/stream-socket/blob/main/LICENSE.md)
[](https://hitsofcode.com/github/zero-to-prod/stream-socket/view?branch=main)
## Contents
- [Introduction](#introduction)
- [Requirements](#requirements)
- [Installation](#installation)
- [Documentation Publishing](#documentation-publishing)
- [Automatic Documentation Publishing](#automatic-documentation-publishing)
- [Usage](#usage)
- [Local Development](./LOCAL_DEVELOPMENT.md)
- [Contributing](#contributing)
## Introduction
A wrapper for the [`stream_socket_client()`](https://www.php.net/manual/en/function.stream-stream-socket.php) method.
It provides classes that define all the options for this method.
## Requirements
- PHP 7.1 or higher.
## Installation
Install `Zerotoprod\StreamSocket` via [Composer](https://getcomposer.org/):
```shell
composer require zero-to-prod/stream-socket
```
This will add the package to your project’s dependencies and create an autoloader entry for it.
## Documentation Publishing
You can publish this README to your local documentation directory.
This can be useful for providing documentation for AI agents.
This can be done using the included script:
```bash
# Publish to default location (./docs/zero-to-prod/stream-socket)
vendor/bin/zero-to-prod-stream-socket
# Publish to custom directory
vendor/bin/zero-to-prod-stream-socket /path/to/your/docs
```
### Automatic Documentation Publishing
You can automatically publish documentation by adding the following to your `composer.json`:
```json
{
"scripts": {
"post-install-cmd": [
"zero-to-prod-stream-socket"
],
"post-update-cmd": [
"zero-to-prod-stream-socket"
]
}
}
```
## Usage
```php
use Zerotoprod\StreamSocket\StreamSocket;
StreamSocket::client(
'ssl://'.$url.':'. 443,
30
STREAM_CLIENT_CONNECT,
stream_context_create()
);
echo $SocketClient->remoteSocketName(); // 34.223.124.45:443
$SocketClient->close();
```
## Contributing
Contributions, issues, and feature requests are welcome!
Feel free to check the [issues](https://github.com/zero-to-prod/stream-socket/issues) page if you want to contribute.
1. Fork the repository.
2. Create a new branch (`git checkout -b feature-branch`).
3. Commit changes (`git commit -m 'Add some feature'`).
4. Push to the branch (`git push origin feature-branch`).
5. Create a new Pull Request.