Recommended Posts

Tasker is a module to handle and execute long-running jobs in Processwire. It provides a simple API  to create tasks (stored as PW pages), to set and query their state (Active, Waiting, Suspended etc.), and to execute them via Cron, LazyCron or HTTP calls.

Creating a task

$task = wire('modules')->Tasker->createTask($class, $method, $page, 'Task title', $arguments);

where $class and $method specify the function that performs the job, $page is the task's parent page and $arguments provide optional configuration for the task.

Executing a task

You need to activate a task first


then Tasker will automatically execute it using one of its schedulers: Unix cron, LazyCron or TaskerAdmin's REST API + JS client.

Getting the job done

Your method that performs the task looks like

public function longTask($page, &$taskData, $params) {

where $taskData is a persistent storage and $params are run-time options for the task.

Monitoring progress, management

The TaskerAdmin module provides a Javascript-based front-end to list tasks, to change their state and to monitor their progress (using a JQuery progressbar and a debug log area). It also allows the on-line execution of tasks using periodic HTTP calls performed by Javascript.



Monitoring task progress (and log messages if debug mode is active)



Task data and log


Detailed info (setup, task dependencies, time limits, REST API etc.) and examples can be found on GitHub.

This is my first public PW module. I'm sure it needs improvement :)


  • Like 12

Share this post

Link to post
Share on other sites

hi @mtwebit welcome to the forum and thanks for that module! i've created something similar for one of my projects but it's custom and not built into a module so i think there's potential for what you are doing :)

some ideas/questions/feedback:

  • use InputfieldMarkup to structure your custom code and make it look&feel more native. see my new tutorial here: 
  • do you know the wirequeue module?
  • would be great to have an easy way to integrate this into other modules or custom pages. maybe it is already possible - i'll have a look when i have more time :)

This is how my progressbar looks like using InputfieldMarkup:

2017-11-09 16_20_28-Edit Page_.png

  • Like 4

Share this post

Link to post
Share on other sites

Thanks for the feedback. I'll definitely have a look at InputfieldMarkup and wirequeue.

It is possible to integrate the UI elements into other pages. There's a renderTaskList() method to perform this:

    if(wire('modules')->isInstalled("TaskerAdmin")) {
      $out .= '<h3>Tasks</h3>';
      $out .= wire('modules')->get('TaskerAdmin')->renderTaskList($selector);

It can render a task list or a detailed task monitoring div including JS code to show the progressbar or even to execute the task when displaying the page.
It needs improvement, however, as its links point to the TaskerAdmin page atm and the list UI is not really customizable.

Share this post

Link to post
Share on other sites

I'm doing something similar (far from being as awesome as your module) using only some hobbled up pages and templates, and it's getting out of hand. This looks worthwhile to dig around in. I'll try it out and try to give helpful feedback. Thanks for sharing. :) 

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By flydev
      Originaly developped by Jeff Starr, Blackhole is a security plugin which trap bad bots, crawlers and spiders in a virtual black hole.
      Once the bots (or any virtual user!) visit the black hole page, they are blocked and denied access for your entire site.
      This helps to keep nonsense spammers, scrapers, scanners, and other malicious hacking tools away from your site, so you can save precious server resources and bandwith for your good visitors.
      How It Works
      You add a rule to your robots.txt that instructs bots to stay away. Good bots will obey the rule, but bad bots will ignore it and follow the link... right into the black hole trap. Once trapped, bad bots are blocked and denied access to your entire site.

      The main benefits of Blackhole include:
       Bots have one chance to obey your site’s robots.txt rules. Failure to comply results in immediate banishment.
      Disable Blackhole for logged in users Optionally redirect all logged-in users Send alert email message Customize email message Choose a custom warning message for bad bots Show a WHOIS Lookup informations Choose a custom blocked message for bad bots Choose a custom HTTP Status Code for blocked bots Choose which bots are whitelisted or not  
      Install the module Create a new page and assign to this page the template "blackhole" Create a new template file "blackhole.php" and call the module $modules->get('Blackhole')->blackhole(); Add the rule to your robot.txt Call the module from your home.php template $modules->get('Blackhole')->blackhole();  Bye bye bad bots!



    • By Robin S
      I got tired of having to open the link dialog in CKEditor in order to check where a link is pointing to, so made this simple plugin.
      Link Hover
      A plugin for CKEditor. Shows the href attribute of a link in a tooltip when the link is hovered. This saves you from having to open the link dialog in order to check where a link points to.

      This readme assumes installation in ProcessWire CMS.
      The plugin folder must be named "linkhover" – if necessary, rename the folder to remove the "-master" suffix added by GitHub. Copy the "linkhover" folder to /site/modules/InputfieldCKEditor/plugins/
      In the field settings for each CKEditor field that you want to activate the plugin for, check the "linkhover" checkbox at Input > Plugins > Extra Plugins
    • By neosin
      I've been reading through the tutorials and have created an admin module based on the ProcessHello example module.
      I have a few questions regarding how to do a few things with the module that are not obvious or covered by the processhello tutorial.
      Outline of expected module functionality:
      The custom module admin setup page should contain a list of its editable pages. CMS users will be able to add/edit/delete pages of this module. The modules editable pages use the same defined fields. The editable pages data will need to be available for use by another custom module. This custom module (called "Stream Encoders") will handle creating/updating/deleting of "Stream Encoders".
      The encoders contain various fields such as encoder name, operational status (is it on or off) and brightcove asset ID
      A second module in "admin>setup" called "Video Streams" will handle creating/updating/deleting/scheduling of "Video Streams".
      Each video stream belongs to a video encoder and uses some of the settings from the encoder selected, such as the encoder title and the brightcove asset ID which on the frontend are used to display the video stream.
      My noob questions:
      Since they are not "pages" in the navigation tree, how do I define these "encoders" to add them to the custom stream encoders module? I don't believe my custom modules should be under "Setup", is it possible to have custom menus in the admin? It's fine if they can't but it would be more intuitive if they had their own menus in the admin instead of living under "Setup". Without having a specific page on the frontend for video streams, how would I access the data for a specific video stream from the home page? for example if I wanted to display a specific or random video stream in a sidebar on the homepage. Are there any tutorials on using scheduling with custom modules? The video streams can be scheduled or turned on/off as desired by the CMS users. thank you in advance
    • By BitPoet
      The module has been lying around on GitHub for some time now, so I thought I'd give it its own forum topic so I can give it a module list entry.
      Symmetric encryption for text based fields (supports multi language fields).
      Module page.
      Link to the GitHub repo.
      This module adds an encryption option to all text fields (and those derived from FieldtypeText).
      Field contents are encrypted using a symmetric key when a page is saved and decrypted when loaded from the database.
      The module by default uses sodium (if loaded) in PHP versions >= 7.2, otherwise it falls back to the bundled phpseclib.
      Multi-Language fields are supported too.
      Setting a field to encrypted and saving values in those fields is a one-way road!
      Once encrypted, the contents cannot be unencrypted without writing a program to do so. Disabling the encryption option on a field after the fact gets you encrypted "garbage".
      Download the zipped module through the green button at the top right of the GitHub repo or (once available there) from the official PW module repository Extract in its own directory under site/modules. In the backend, click "Modules" -> "Refresh", then install "Symmetric Encryption for Text Fields". Go to module settings. An appropriately sized, random key will be generated if this is your first use. Copy the supplied entry into site/config.php Add fields or configure already present fields. On the "Details" tab you can enable encryption for the field in question Edit a page with such a field, enter a value there, save and enjoy Existing, unencrypted values are left untouched until a new value is saved. That way, you can do a smooth upgrade to encryption, but you have to save all pre-populated pages to have their values encrypted in the database. Thus it is recommended to avoid adding encryption to already populated fields.
      Advanced Usage
      You can hook after SymmetricEncryptedText::loadKey to retrieve your key from somewhere else, e.g. a different server.
    • By BitPoet
      After building the ProcessMentions module and another autocomplete module for images, I found that I am going to need even more of these, but things were going to get repetitive. So I refactored the whole thing into a basic autocompletion module and individual "actions".
      The result is Autocomplete for CKEditor (GitHub).
      To try out,
      Install the module and actions

        Enable actions in the settings of any CKEditor field

        Edit a page with this field, type "@" and some characters for the  and enjoy
      There are still a few things I need to implement. ATM, it only supports single characters as triggers for the autocomplete. I'd like to change that to combinations so I don't run out of special characters at some point. I also have to add a few more configuration options (like search only at the beginning or also in the middle of the searched string). The documentation for custom styling also needs some work.
      I have tried to keep things generic. Implementing your own actions should be quite straight forward. The README at GitHub illustrates the main steps and the supplied action classes have inline documentation. I would love to get some feedback or even see some third party InlineCompleteAction implementations.