strukt/tasker

Simple php task manager

v1.0.1-alpha 2022-05-24 19:00 UTC

This package is auto-updated.

Last update: 2024-04-24 23:17:30 UTC


README

A simple task manager for php.

Getting started

wget https://github.com/samweru/strukt-tasker/releases/download/v1.0.1-alpha/tasker.phar #download
chmod a+x tasker.phar #make executable
mv tasker.phar tasker #rename

Usage

By default, task manager will create tasker.php file if one isn't found when you execute the tasker command.

The intial tasker.php file contains a single command test.

How to list commands:

$ tasker list

 version         Tasker version
 list            List commands
 test            Sample task

Below is sample tasker.php

/**
 * Show today's date
 */
task('date', function(){

	$date = new \DateTime();

	echo(sprintf("Now: %s\n", $date->format("Y-m-d H:i:s")));
});

/**
 * Say hello to someone
 */
task("hello", function(string $name){

    writeln(sprintf("Hello %s!", $name));
});

/**
 * Say hello to the world
 */
task('test', function(){

    go("hello", " World!");
});

/**
 * Watch changes in javascript files
 */ 
task("watch:js", function(){

	watch("app/js", function($files){

		$changes = [];
		foreach($files as $file)
			$changes[] = sprintf("%s\n", $file);

		print_r(implode("\n", $changes));
	});
});

/**
 * List directories
 */
task("lsdir", function(){

	list($output, $error) = run("ls -al", function($output){

		echo $output;
	});
});

Boxing

First you'll need to install phive

wget -O phive.phar https://phar.io/releases/phive.phar
wget -O phive.phar.asc https://phar.io/releases/phive.phar.asc
gpg --keyserver hkps://keys.openpgp.org --recv-keys 0x9D8A98B29B2D5D79
gpg --verify phive.phar.asc phive.phar
chmod +x phive.phar
sudo mv phive.phar /usr/local/bin/phive

Then, install Box globally.

phive install humbug/box --force-accept-unsigned

..and update.

phive update humbug/box --force-accept-unsigned

..or install Box locally.

composer require --dev bamarni/composer-bin-plugin
composer bin box require --dev humbug/box

vendor/bin/box

..or

$ curl -LSs https://box-project.github.io/box2/installer.php | php