https://github.com/viloveul/transport
Simple message transport with amqp
https://github.com/viloveul/transport
amqp communication component library php transport viloveul viloveul-framework
Last synced: 6 months ago
JSON representation
Simple message transport with amqp
- Host: GitHub
- URL: https://github.com/viloveul/transport
- Owner: viloveul
- Created: 2019-03-09T17:39:27.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2021-07-19T04:21:11.000Z (almost 5 years ago)
- Last Synced: 2025-07-29T00:07:36.636Z (11 months ago)
- Topics: amqp, communication, component, library, php, transport, viloveul, viloveul-framework
- Language: PHP
- Homepage:
- Size: 18.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
Awesome Lists containing this project
README
```shell
composer require viloveul/transport
```
## SETUP
initilize bus connection for data transport
```php
require_once __DIR__ . '/vendor/autoload.php';
$bus = new Viloveul\Transport\Bus();
$bus->initialize();
$bus->addConnection('amqp://localhost:5672//');
```
declaring class passenger (for whatever your data)
```php
use Viloveul\Transport\Passenger;
class TaskPassenger extends Passenger
{
public function point(): string
{
return 'exchange name';
}
public function route(): string
{
return 'routing.key';
}
public function data(): string
{
return 'string-data';
}
public function handle(): void
{
$this->setAttribute('data', [
'foo' => 'bar'
]);
}
}
```
## BROKER MESSAGE (RabbitMQ)
run rabbit under docker
```bash
docker run --rm -p 5672:5672 rabbitmq:3
# rabbitmq listen for port 5672
```
processing task
```php
$bus->process(new TaskPassenger);
```
## BACKEND (using Celery)
```shell
cd sample/celery
celery -A tasks worker --loglevel=info
```
## BACKEND (websocket)
```shell
cd sample/socket.io
npm install
npm start
```