Skip to content

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
Plytas committed Mar 31, 2023
1 parent d2ad8b5 commit ee7dcb9
Showing 1 changed file with 34 additions and 21 deletions.
55 changes: 34 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,27 @@
[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/pollsockets/pollsockets-laravel/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=flat-square)](https://github.com/pollsockets/pollsockets-laravel/actions?query=workflow%3A"Fix+PHP+code+style+issues"+branch%3Amain)
[![Total Downloads](https://img.shields.io/packagist/dt/pollsockets/pollsockets-laravel.svg?style=flat-square)](https://packagist.org/packages/pollsockets/pollsockets-laravel)

This is where your description should go. Limit it to a paragraph or two. Consider adding a small example.
## Why pollsockets?

Pollsockets is a simple, yet powerful, server-client communication library. It is designed to be used in situations where you need to send data from the server to the client. It is a great alternative to websockets, as it is much simpler to implement and use.

## How does it work?

Pollsockets uses a simple polling mechanism to send events from the server to the client. Instead of polling an endpoint that returns data, pollsockets polls an endpoint that returns a list of events that have occurred, thus saving bandwidth and response time. The client then processes the events and updates the UI accordingly.

## Ecosystem

### Server side
- [Laravel](https://github.com/pollsockets/pollsockets-laravel)

### Client side
- [Javascript](https://github.com/pollsockets/pollsockets-js)

## Requirements

- PHP 8.1 or higher
- Laravel 9.0 or higher
- Redis 6.0 or higher

## Installation

Expand All @@ -15,37 +35,34 @@ You can install the package via composer:
composer require pollsockets/pollsockets-laravel
```

You can publish and run the migrations with:

```bash
php artisan vendor:publish --tag="pollsockets-laravel-migrations"
php artisan migrate
```

You can publish the config file with:

```bash
php artisan vendor:publish --tag="pollsockets-laravel-config"
php artisan vendor:publish --tag="pollsockets-config"
```

This is the contents of the published config file:

```php
use Pollsockets\Drivers\RedisChannel;

return [
'driver' => RedisChannel::class,
];
```

Optionally, you can publish the views using

```bash
php artisan vendor:publish --tag="pollsockets-laravel-views"
```

## Usage

```php
$pollsockets = new Pollsockets\Pollsockets();
echo $pollsockets->echoPhrase('Hello, Pollsockets!');
use Pollsockets\Pollsockets;

// Channel name can be any string. Can be used to separate events from different sources.
$channelName = 'channel';
// Event name can be any string. Can be used to separate events of the same type.
$event = 'reload';

// Publish an event to the channel from anywhere in your code. Perfect for informing client about changes in the database.
Pollsockets::channel($channelName)->publish($event);
```

## Testing
Expand All @@ -58,10 +75,6 @@ composer test

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

## Contributing

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

## Security Vulnerabilities

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.
Expand Down

0 comments on commit ee7dcb9

Please sign in to comment.