{"id":19012170,"url":"https://github.com/garlicservices/bus-bundle","last_synced_at":"2025-04-22T23:40:47.318Z","repository":{"id":62509088,"uuid":"113882408","full_name":"garlicservices/bus-bundle","owner":"garlicservices","description":"Symfony 4 Message Bus bundle for Garlic microservices","archived":false,"fork":false,"pushed_at":"2019-04-22T11:24:59.000Z","size":108,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-17T16:03:56.986Z","etag":null,"topics":["bus-bundle","communication","composer-package","garlic-bus","message-bus","symfony-bundle"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/garlicservices.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-11T16:31:14.000Z","updated_at":"2019-04-22T11:24:14.000Z","dependencies_parsed_at":"2022-11-02T13:16:24.660Z","dependency_job_id":null,"html_url":"https://github.com/garlicservices/bus-bundle","commit_stats":null,"previous_names":[],"tags_count":39,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garlicservices%2Fbus-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garlicservices%2Fbus-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garlicservices%2Fbus-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/garlicservices%2Fbus-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/garlicservices","download_url":"https://codeload.github.com/garlicservices/bus-bundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250343632,"owners_count":21415035,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bus-bundle","communication","composer-package","garlic-bus","message-bus","symfony-bundle"],"created_at":"2024-11-08T19:17:03.094Z","updated_at":"2025-04-22T23:40:47.300Z","avatar_url":"https://github.com/garlicservices.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Garlic message bus\n\nThis bundle allow microservices communicate to each other with RabbitMQ transport by providing message bus.\n\nFor correct usage the Bundle must be installed on both ends of communication (current and target services)\n\n## Installation\n\nJust a couple things are necessary for this bundle works. \n\n### Add garlic/bus bundle to your composer.json\n\n```bash\ncomposer require garlic/bus\n```\n\n### Run processor as a Daemon (add configuration to your supervisor.conf)\n\n```bash\n[program:garlic_communication]\ncommand=/var/www/bin/console --env=prod --no-debug enqueue:consume --setup-broker\nprocess_name=%(program_name)s_%(process_num)02d\nnumprocs=4\nautostart=true\nautorestart=true\ntartsecs=0\nuser=www-data\nredirect_stderr=true\n```\n\nNow you can use Garlic Bus\n\n### Optional: You can set timeout which will used to wait for response\n\nSet variable REQUEST_TIMEOUT=30 where 30 is seconds\n\n## Usage\n\n### Common way to use \n\nIf you want to get response from current service you have to use 'request' method, like explained below\n\n```php\n$data = $this-\u003eget('communicator') // Or you can call by class name. Example: $this-\u003eget(GarlicBus:class)\n    -\u003erequest('targetServiceName') // Type of message. So far you can use -\u003erequest() or -\u003ecommand() methods. Command provide mesage type that not need response. \n    -\u003epost()                       // Set one of REST methods (post, put, delete). Bu default set GET \n    -\u003etargetServiceAction(         // CamelCased route where slashes vere changed to upper letter by magic (example: getUser will changed to /get/user)\n        array $path = [],          // Path parameters to query (example: ['user' =\u003e 1])\n        array $query = [],         // Post or Get parameters to the query\n        array $headers = []        // Additional headers\n    );\n    \n```\nor the same but using direct rout as a method parameter\n```php\n$data = $this-\u003eget('communicator')\n    -\u003erequest('targetServiceName')\n    -\u003esend(\n        string $route, // Route to the target service action (example: /user/get)\n        array $path = [], \n        array $query = [],\n        array $headers = [] \n    );\n    \n```\n\n#### Making async batch request with parallel processing\n\n```php\n$data = $this-\u003eget('communicator')\n    -\u003epool(\n        'service1', // Target service name\n        '/',        // Route to the target service action (example: /user/get)\n        [],         // Path parameters to query\n        [],         // Post or Get parameters to the query\n        []          // Request headers\n    )\n    -\u003epool(\n        'service1', // Target service name\n        '/',        // Route to the target service action (example: /user/get)\n        [],         // Path parameters to query\n        [],         // Post or Get parameters to the query\n        []          // Request headers\n        )\n    -\u003efetch();      // Get response from async queries pool\n```\n\n#### Working with files\nmake sure you add variables to .env\n```\n### host url, will be used by another service to get files from current service\nHOST_URL=172.18.1.14\n\n###files will be uploaded to this dir\nUPLOAD_DIR = public/upload\n\n###should be same for every service using same bus\nSCP_USERNAME=www-data\nSCP_PASSWORD=KJLgbJ32PIHDJU4\n```\nupload files from Request\n```\n $handler = $this-\u003eget('Garlic\\Bus\\Service\\File\\FileHandlerService');\n $handler-\u003ehandleFiles($_FILES['pictures']);\n```\nget file from another service\n```\n $uploader = $this-\u003eget('Garlic\\Bus\\Service\\File\\ScpFileUploadService');\n $uploader-\u003egetFile(['host_url' =\u003e '172.18.0.1','origin_name' =\u003e '1.jpg','path' =\u003e 'public/upload/fsdljkahb.jpg']);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarlicservices%2Fbus-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgarlicservices%2Fbus-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgarlicservices%2Fbus-bundle/lists"}