Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

TNT Studio:
Easy way of sending scheduled tasks output to Slack
Jul 06, 2016 @ 16:20:12

On the TNT Studio site they've posted a tutorial showing you how to automate scheduled tasks and output to Slack, the popular online communication tool (think IRC for the web). They show how to use a simple webhook setup to relay the results of a task back to a given channel.

What many of us grow accustomed to is having cron job output emailed to us in order to see if everything went ok. Laravel's task scheduler also supports emailing output of the commands but if you are like millions of developers out there then you are probably using Slack and it's possible that it crossed your mind that it would be great if we could get output of the cron command sent to Slack. So let's do that.

They then walk you through the setup of the Slack notifier class to send the data to Slack via a Guzzle POSTed request. The next portion puts this code to work and creates the code to execute the command and return the results. The "after" event is then used to make the Slack request and output the results to the waiting channel.

tagged: output slack channel chat cronjob scheduled results output guzzle

Link: http://tnt.studio/blog/task-scheduling-output-to-slack


Trending Topics: