PHP code example of gravitask / task
1. Go to this page and download the library: Download gravitask/task library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gravitask / task example snippets
$parser = new Gravitask\Task\Parser\TodoTxtParser();
$input = "(A) Write the README file";
$task = $parser->parse($input);
$task->getPriority(); // Result: "A"
$task->getTask(); // Result: "Write the README file"
$taskItem->setTask("Make another coffee");
$task->getTask();
// "Make another coffee"
$contexts = ['email', 'computer'];
$task->setContexts($contexts);
$contexts = ['email'];
$task->setContexts($contexts);
$task->addContext('computer');
$contexts = ['email', 'computer'];
$task->setContexts($contexts);
$task->getContexts();
// ['email', 'computer']
$projects = ['SecretProject'];
$task->setProjects($projects);
$projects = ['SecretProject'];
$task->setProjects($projects);
$task->addProject('Work');
$projects = ['SecretProject'];
$task->setProjects($projects);
$task->addProject('Work');
$task->getProjects();
// ['SecretProject', 'Work']
$creationDate = new \DateTime::createFromFormat("Y-m-d", "2016-08-16");
$task->setCreationDate($creaionDate);
$task->getCreationDate();
// \DateTime object
$task->setStatus(TaskItem::STATUS_COMPLETED);
$completionDate = new \DateTime::createFromFormat("Y-m-d", "2016-08-20");
$task->setCompletionDate($completionDate);
$task->setStatus(TaskItem::STATUS_COMPLETED);
$completionDate = new \DateTime::createFromFormat("Y-m-d", "2016-08-20");
$task->setCompletionDate($completionDate);
$task->getCompletionDate()
// \DateTime object
$task->setPriority("B");
$task->setPriority("F");
$task->getPriority();
// "F"
$task->setStatus(TaskItem::STATUS_COMPLETED);
$task->setStatus(TaskItem::STATUS_COMPLETED);
$task->getStatus();
// Integer value representation of the status ENUM.
$task->setPriority("A");
$task->setTask("Write example code");
$formatter = new Gravitask\Task\Formatter\TodoTxtFormatter();
$output = $formatter->format($task);
// "(A) Write example code"
$parser = new Gravitask\Task\Parser\TodoTxtParser();
$input = "(A) Write the README file";
$task = $parser->parse($input);
$task->getPriority(); // Result: "A"
$task->getTask(); // Result: "Write the README file"