Go to file
DavidBadura e04ae2b2a7 cleanup tests 2015-09-18 17:12:36 +00:00
build try taskwarrior 2.5.0.beta1 2015-09-15 14:46:55 +02:00
src allow dots in projects and tasks 2015-07-25 11:02:18 +02:00
tests cleanup tests 2015-09-18 17:12:36 +00:00
.gitignore first draft 2015-02-05 20:41:03 +01:00
.travis.yml try taskwarrior 2.5.0.beta1 2015-09-15 14:46:55 +02:00
LICENSE Initial commit 2015-02-05 14:24:24 +01:00
README.md update readme 2015-07-08 13:41:05 +02:00
composer.json support ~ for home directory in paths 2015-07-15 01:26:06 +02:00
phpunit.xml.dist first draft 2015-02-05 20:41:03 +01:00

README.md

Taskwarrior PHP lib

used by doThings - a Taskwarrior web-ui.

Build Status

WOW

Install

composer require 'davidbadura/taskwarrior'

Unfortunately, the annotation reader is not automatically registered on composer. So you should add following line if you have [Semantical Error] The annotation "@JMS\Serializer\Annotation\Type" in property [...] does not exist, or could not be auto-loaded. exception:

\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader('class_exists');

Requirements

Taskwarrior changes its behavior by patch level updates and it is very difficult to support all versions. The current supported versions are: >=2.4.3

Usage

use DavidBadura\Taskwarrior\TaskManager;
use DavidBadura\Taskwarrior\Task;
use DavidBadura\Taskwarrior\Recurring;

$tm = TaskManager::create();

$task = new Task();
$task->setDescription('program this lib');
$task->setProject('hobby');
$task->setDue('tomorrow');
$task->setPriority(Task::PRIORITY_HIGH);
$task->addTag('next');
$task->setRecurring(Recurring::DAILY);

$tm->save($task);

$tasks = $tm->filterPending('project:hobby'); // one task

$tm->done($task);

$tasks = $tm->filterPending('project:hobby'); // empty
$tasks = $tm->filter('project:hobby'); // one task

$tasks = $tm->filterByReport('waiting'); // and sorting

API

Task

attr writeable type
uuid false string
description true string
priority true string
project true string
due true DateTime
wait true DateTime
tags true string[]
urgency false float
entry false DateTime
start false DateTime
recur true Recurring
unti true DateTime
modified false DateTime
end false DateTime
status false string

Example:

$task = new Task();
$task->setDescription('program this lib');
$task->setProject('hobby');
$task->setDue('tomorrow');
$task->setPriority(Task::PRIORITY_HIGH);
$task->addTag('next');
$task->setRecurring(Recurring::DAILY);

Taskwarrior

create TaskManager:

$tm = TaskManager::create();

save a task:

$task = new Task();
$task->setDescription('foo');
$tm->save($task);

find a task:

$task = $tm->find('b1d46c75-63cc-4753-a20f-a0b376f1ead0');

filter tasks:

$tasks = $tm->filter('status:pending');
$tasks = $tm->filter('status:pending +home');
$tasks = $tm->filter('status:pending and +home');
$tasks = $tm->filter(['status:pending', '+home']);

filter pending tasks:

$tasks = $tm->filterPending('+home');
$tasks = $tm->filterPending('project:hobby +home');
$tasks = $tm->filterPending('project:hobby and +home');
$tasks = $tm->filterPending(['project:hobby', '+home']);

delete task:

$tm->delete($task);

done task:

$tm->done($task);

start task:

$tm->start($task);

stop task:

$tm->stop($task);

reopen task:

$tm->reopen($task);

dependencies:

$task1 = new Task();
$task1->setDescription('a');

$task2 = new Task();
$task2->setDescription('b');

$task1->addDependency($task2);

// the order is important!
$tm->save($task2);
$tm->save($task1);

$tm->clear(); // clear object cache

$task1 = $tm->find('uuid-from-task1');
$task2 = $task1->getDependencies()[0];
echo $task2->getDesciption(); // "b" <- lazy loading

QueryBuilder

example:

$tasks = $taskManager->createQueryBuilder()
    ->whereProject('hobby')
    ->orderBy(['entry' => 'DESC'])
    ->getResult()