{"id":44882537,"url":"https://github.com/phlib/beanstalk","last_synced_at":"2026-02-17T16:31:05.042Z","repository":{"id":18537379,"uuid":"21738175","full_name":"phlib/beanstalk","owner":"phlib","description":"PHP beanstalk connection and connection pool library","archived":false,"fork":false,"pushed_at":"2025-07-31T11:07:47.000Z","size":479,"stargazers_count":9,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-10-03T20:52:48.759Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phlib.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-07-11T14:04:05.000Z","updated_at":"2025-07-31T11:07:50.000Z","dependencies_parsed_at":"2025-01-26T10:20:39.911Z","dependency_job_id":"d0b59bc2-c1bd-4e10-ac36-ea03a1f34e0b","html_url":"https://github.com/phlib/beanstalk","commit_stats":{"total_commits":196,"total_committers":5,"mean_commits":39.2,"dds":0.3112244897959183,"last_synced_commit":"d2066f5114bfb202204636c5e4b500be87571c93"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/phlib/beanstalk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phlib%2Fbeanstalk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phlib%2Fbeanstalk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phlib%2Fbeanstalk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phlib%2Fbeanstalk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phlib","download_url":"https://codeload.github.com/phlib/beanstalk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phlib%2Fbeanstalk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29549795,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T14:33:00.708Z","status":"ssl_error","status_checked_at":"2026-02-17T14:32:58.657Z","response_time":100,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-02-17T16:31:04.256Z","updated_at":"2026-02-17T16:31:05.037Z","avatar_url":"https://github.com/phlib.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# phlib/beanstalk\n\n[![Code Checks](https://img.shields.io/github/actions/workflow/status/phlib/beanstalk/code-checks.yml?logo=github)](https://github.com/phlib/beanstalk/actions/workflows/code-checks.yml)\n[![Codecov](https://img.shields.io/codecov/c/github/phlib/beanstalk.svg?logo=codecov)](https://codecov.io/gh/phlib/beanstalk)\n[![Latest Stable Version](https://img.shields.io/packagist/v/phlib/beanstalk.svg?logo=packagist)](https://packagist.org/packages/phlib/beanstalk)\n[![Total Downloads](https://img.shields.io/packagist/dt/phlib/beanstalk.svg?logo=packagist)](https://packagist.org/packages/phlib/beanstalk)\n![Licence](https://img.shields.io/github/license/phlib/beanstalk.svg)\n\nBeanstalkd library implementation.\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require phlib/beanstalk\n```\n\n## Basic Usage\n\n``` php\n\u003c?php\nuse Phlib\\Beanstalk\\Connection;\n\n// producer\n$beanstalk = new Connection('127.0.0.1');\n$beanstalk-\u003euseTube('my-tube');\n$beanstalk-\u003eput(array('my' =\u003e 'jobData'));\n```\n\n``` php\n\u003c?php\nuse Phlib\\Beanstalk\\Connection;\n\n// consumer\n$beanstalk = new Connection('127.0.0.1');\n$beanstalk-\u003ewatch('my-tube')\n    -\u003eignore('default');\n$job = $beanstalk-\u003ereserve();\n$myJobData = $job['body'];\n$beanstalk-\u003edelete($job['id']);\n```\n\n## Connection configuration\n\n|Name|Type|Required|Default|Description|\n|----|----|--------|-------|-----------|\n|`host`|*String*|Yes| |Hostname or IP address.|\n|`port`|*Integer*|No|`11300`|Beanstalk's port.|\n|`options`|*Array*|No|`\u003cempty\u003e`|Connection options for Beanstalk.|\n\n### Options\n\n|Name|Type|Default|Description|\n|----|----|-------|-----------|\n|`timeout`|*Integer*|`60`|The connection timeout.|\n\n## Pool configuration\n\n|Name|Type|Required|Default|Description|\n|----|----|--------|-------|-----------|\n|`connections`|*ConnectionInterface[]*|Yes| |Array of server connections.|\n|`retryDelay`|*Integer*|No|`600`|How long to delay retrying a connection for after an error.|\n|`logger`|*LoggerInterface*|No| |Optional Logger to capture connection failures.|\n\n## Factory\nThe factory allows for easy setup of the objects.\nThis especially useful when creating a pool of beanstalk servers.\nThe following example lists the various ways it can be used.\nThe configuration examples in the command line section are created\nusing the factory.\n\n```php\n$factory = new \\Phlib\\Beanstalk\\Factory();\n\n$beanstalk = $factory-\u003ecreate('localhost');\n\n$beanstalk = $factory-\u003ecreateFromArray([\n    'host' =\u003e 'localhost',\n]);\n\n$beanstalk = $factory-\u003ecreateFromArray([\n    ['host' =\u003e '10.0.0.1'],\n    ['host' =\u003e '10.0.0.2'],\n    ['host' =\u003e '10.0.0.3'],\n]);\n```\n\n### Factory Configuration\nThe configuration options are as specified above.\nWith the exception that when creating a pool there is an optional `enabled`.\n\n```php\n$factory = new \\Phlib\\Beanstalk\\Factory();\n\n$beanstalk = $factory-\u003ecreateFromArray([\n    ['host' =\u003e '10.0.0.1', 'enabled' =\u003e true],\n    ['host' =\u003e '10.0.0.2', 'enabled' =\u003e false],\n    ['host' =\u003e '10.0.0.3', 'enabled' =\u003e true],\n]);\n```\n\n## Pool\nThe pool allows for work to be pushed to and retrieved from multiple servers.\nThe pool implements the connection interface.\n\n```php\nuse Phlib\\Beanstalk\\Connection;\nuse Phlib\\Beanstalk\\Pool;\n\n$connections = [\n    new Connection('10.0.0.1'),\n    new Connection('10.0.0.2'),\n    new Connection('10.0.0.3'),\n    new Connection('10.0.0.4'),\n];\n$logger = new MyLogger();\n$pool = new Pool($connections, 120, $logger);\n\n$pool-\u003euseTube('my-tube');\n$pool-\u003eput(array('my' =\u003e 'jobData1')); // )\n$pool-\u003eput(array('my' =\u003e 'jobData2')); // )-\u003e distributed between random servers\n$pool-\u003eput(array('my' =\u003e 'jobData3')); // )\n```\n\nAlternative way to create a Pool, using the Factory to construct the\nconnections:\n\n```php\nuse Phlib\\Beanstalk\\Factory;\nuse Phlib\\Beanstalk\\Pool;\n\n$connections = (new Factory())-\u003ecreateConnections([\n    ['host' =\u003e '10.0.0.1', 'enabled' =\u003e true],\n    ['host' =\u003e '10.0.0.2', 'enabled' =\u003e false],\n    ['host' =\u003e '10.0.0.3', 'enabled' =\u003e true],\n]);\n$logger = new MyLogger();\n$pool = new Pool($connections, 120, $logger);\n```\n\n## Command Line Script\n\n```bash\n./vendor/bin/beanstalk\n```\n\nRunning the script will provide you with a list of options.\nMost are self-explanatory.\nBy default no configuration is required, the script will default to localhost.\n\n### Command Line Configuration\n\nThere are 2 ways of specifying a configuration.\n\n1. Create a file called *beanstalk-config.php* either in\n   ```/app/root/``` or ```/app/root/config/```.\n2. Create a file with a name of your choosing and specify it\n   using the command option ```-c /path/to/my/config.php```.\n\nThe file must return an array containing the beanstalk configuration.\nThis configuration will be passed to the Factory to create an instance.\n\n```php\nreturn [\n    'host' =\u003e '10.0.0.1',\n    'port' =\u003e 11300\n];\n```\n\n```php\n// pool configuration\nreturn [\n    [\n        'host' =\u003e '10.0.0.1',\n        'port' =\u003e 11300,\n    ],\n    [\n        'host' =\u003e '10.0.0.2',\n        'port' =\u003e 11300,\n    ],\n    [\n        'host' =\u003e '10.0.0.3',\n        'port' =\u003e 11300,\n        'enabled' =\u003e false,\n    ],\n];\n```\n\n```php\nrequire_once 'my/app/bootstrap.php';\n\n$app = new MyApp();\nreturn $app['config']['beanstalk'];\n\n```\n\n## License\n\nThis package is free software: you can redistribute it and/or modify\nit under the terms of the GNU Lesser General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU Lesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with this program.  If not, see \u003chttp://www.gnu.org/licenses/\u003e.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphlib%2Fbeanstalk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphlib%2Fbeanstalk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphlib%2Fbeanstalk/lists"}