https://github.com/mohamed-samir907/poller
Do a Server Polling with PHP in a simple way
https://github.com/mohamed-samir907/poller
laravel laravel-framework php php-framework php8 phpunit polling
Last synced: 3 months ago
JSON representation
Do a Server Polling with PHP in a simple way
- Host: GitHub
- URL: https://github.com/mohamed-samir907/poller
- Owner: mohamed-samir907
- License: mit
- Created: 2023-04-24T14:36:04.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-04-24T14:37:40.000Z (about 2 years ago)
- Last Synced: 2025-01-24T08:31:34.044Z (5 months ago)
- Topics: laravel, laravel-framework, php, php-framework, php8, phpunit, polling
- Language: PHP
- Homepage:
- Size: 575 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# PHP Poller
[](https://packagist.org/packages/mosamirzz/poller)
[](https://packagist.org/packages/mosamirzz/poller)

A very simple way to do a Polling mechanism using PHP.
## Installation
You can install the package via composer:
```bash
composer require mosamirzz/poller
```## Usage
```php
$result = Poller::do(
fn () => Http::get("https://ads-api.tiktok.com/api/status/get/", [
"advertiser_id" => 12345678,
"task_id" => 23456789,
])
)->every(seconds: 5)
->failAfter(attempts: 3)
->stopWhen(
fn (mixed $result): bool => $result["status"] == "SUCCESS"
)
->onFail(function (Throwable $e) {
Log::error("Got an error", [
"msg" => $e->getMessage(),
"code" => $e->getCode(),
]);
})
->start();
```### Testing
```bash
composer test
```### Changelog
Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.
## Contributing
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
### Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
## Credits
- [Mohamed Samir](https://github.com/poller)
- [All Contributors](../../contributors)## License
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
## PHP Package Boilerplate
This package was generated using the [PHP Package Boilerplate](https://laravelpackageboilerplate.com) by [Beyond Code](http://beyondco.de/).