{"id":19450885,"url":"https://github.com/morning-train/wp-queue","last_synced_at":"2025-08-22T12:32:40.484Z","repository":{"id":65208442,"uuid":"587739844","full_name":"Morning-Train/wp-queue","owner":"Morning-Train","description":"Queue system for WordPress","archived":false,"fork":false,"pushed_at":"2023-07-06T07:41:26.000Z","size":32,"stargazers_count":2,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-28T16:07:14.766Z","etag":null,"topics":["job-queue","queue","queue-workers","wordpress","wp"],"latest_commit_sha":null,"homepage":null,"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/Morning-Train.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-11T13:27:57.000Z","updated_at":"2024-05-03T09:40:44.000Z","dependencies_parsed_at":"2024-11-10T16:40:48.863Z","dependency_job_id":null,"html_url":"https://github.com/Morning-Train/wp-queue","commit_stats":{"total_commits":16,"total_committers":2,"mean_commits":8.0,"dds":0.0625,"last_synced_commit":"af47d87722836cfd51caafd775399e0c65de270f"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/Morning-Train/wp-queue","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2Fwp-queue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2Fwp-queue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2Fwp-queue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2Fwp-queue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Morning-Train","download_url":"https://codeload.github.com/Morning-Train/wp-queue/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morning-Train%2Fwp-queue/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263379522,"owners_count":23457862,"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":["job-queue","queue","queue-workers","wordpress","wp"],"created_at":"2024-11-10T16:39:21.191Z","updated_at":"2025-07-03T18:33:31.177Z","avatar_url":"https://github.com/Morning-Train.png","language":"PHP","readme":"# Morningtrain\\WP\\Queue\n\nQueue system for WordPress.\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Getting Started](#getting-started)\n  - [Installation](#installation)\n- [Usage](#usage)\n  - [Register Worker](#register-worker)\n  - [Create a Job](#create-a-job)\n  - [Running the Queue Worker](#running-the-queue-worker)\n- [Credits](#credits)\n- [License](#license)\n\n## Introduction\n\nThis package is made to dispatch jobs to a queue system.\n\nIt is implementet with WP CLI so it can be runned from the command line.\n\n## Getting started\n\nTo get started install the package as described below in [Installation](#installation).\n\nTo use the package have a look at [Usage](#usage)\n\n### Installation\n\nInstall with composer.\n\n```composer require morningtrain/wp-queue```\n\n## Usage\n\n### Register Worker\n\nTo get started with the module simply register a job queue `\\Morningtrain\\WP\\Queue\\Queue::registerWorker()`.\n\nYou can change name of the job queue from default `job_queue`.\nYou can change the version of the job queue database table from default `1.0.0`.\n\n```php\n\\Morningtrain\\WP\\Queue\\Queue::registerWorker();\n```\n\n### Create a Job\nJobs can be created by extending `Morningtrain\\WP\\Queue\\Abstracts\\AbstractJob` and create a `handle` method.\n\nYou can define which job_queue the job should use by setting the `$worker` parameter to the job queue slug.\n\nNow you can put a job in the queue by calling the static method `dispatch` on your Job class.\n\n```php\n// Job/TestJob.php\nuse Morningtrain\\WP\\Queue\\Abstracts\\AbstractJob;\n\nclass TestJob extends AbstractJob {\n\n  public static function handle(mixed $args) : mixed\n  {\n    // Do something\n    return 'testing...';\n  }\n}\n```\n\n```php \n// Another file\nTestJob::dispatch('test_arg');\n```\n\n#### Alternatively Job Creation\nJobs can alternativley be created directly from the worker, by passing a callback to the `createJob` method.\n\n```php\n\\Morningtrain\\WP\\Queue\\Classes\\Worker::getWorker('job_queue')-\u003ecreateJob($callback, $args);\n```\n\n#### Arguments\nIf you use arguments in your jobs, you have to be aware, that we are using `call_user_func_array`. \nSo if you pass an array, you need to have same number of arguments in your method as you have in your array. And if keyed, the arguments in the method must be called the same as the keys.\n\nIf you do not know the number of arguments in your array or you just need to work on an data array, you can use `...$args` in your method.\nOr you can wrap your array in an extra array containing only the one argument.\n\nSee more about `call_user_func_arrey` on the [PHP documentation](https://www.php.net/manual/en/function.call-user-func-array.php)\n\n### Running the Queue Worker\nUse WP CLI to run the job queue. See [WP CLI documentation](https://wp-cli.org/).\n\n#### Start Worker\n\nStart job queue with the `wp queue start` command and the worker slug.\n\n```\nwp queue start job_queue\n```\n\n\u003e **Note**\n\u003e \n\u003e The worker will run until it is manually stopped or the terminal is closed. \n\u003e You should use a process monitor such as [Supervisor](http://supervisord.org/index.html) to make sure the process does not stop unintended.\n\nYou can run multiple workers simultaneously. \n\n#### Stop Worker\n\nTo stop a worker that you can not stop by closing you terminal, you can use the `stop` command with the worker slug.\n\n```\nwp queue stop job_queue\n```\n\nTo stop all workers use `all` instead of worker slug.\n\n```\nwp queue stop all\n```\n\n#### List available workers\nTo list available workers and their status, use the `list` command\n\n```\nwp queue list\n```\n\n#### Process a Specific Job\n\nCall `wp queue run` with the worker slug and the job ID to process the specific job.\n\n```\nwp queue run job_queue 99\n```\n\n\u003e **Note**\n\u003e\n\u003e You can use --untouched to not set run_date and result\n\u003e ```wp queue run jon_queue 99 --untouched```\n\u003e \n\u003e You can use --force to force the job to run even though it has run before\n\u003e ```wp queue run jon_queue 99 --force```\n\n## Credits\n\n- [Martin Schadegg Brønniche](https://github.com/mschadegg)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorning-train%2Fwp-queue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorning-train%2Fwp-queue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorning-train%2Fwp-queue/lists"}