tshw/php-todo-txt 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tshw/php-todo-txt

Composer 安装命令:

composer require tshw/php-todo-txt

包简介

PHP library for the todo.txt unstructured todo list format.

README 文档

README

PHP library for the todo.txt unstructured todo list format.

What is todo.txt?

It's a simple file format for the todo text file that many people probably have on their desktop somewhere.

A todo.txt file following this standard looks like this:

A simple task is just a line
x This task is done, indicated by the lowercase x
(F) Prioritization is important, so this is priority F
2025-01-01 This task has its creation date mentioned
x 2025-01-01 2024-05-01 This task is done and has a completion and creation date
For +myCoolProject I need to write documentation
When I'm @work I need to plan my next vacation

You get the gist. It's simple, but more structured than just writing down stuff.

To lean more, you can head to todotxt.org to learn more.

Features

  • Robustly parses the todo.txt
  • Provides an easy-to-use model to access and modify tasks
  • Task description is available als "clean" version without trailing tags
  • Projects, contexts and meta data are available separately as arrays

Installation

Use composer to add as dependency:

$ composer require tshw/php-todo-txt

Usage

Create an object of the main class by reading tasks from a file:

<?php
require 'vendor/autoload.php';

$todos = \PhpTodoTxt\TodoTxt::readFromFile(new \SplFileInfo("todo.txt"));
// or if don't want to think about the SPL
$todos = \PhpTodoTxt\TodoTxt::readFromFile("todo.txt");

List all tasks:

foreach ($todos as $task) {
   echo $task->getText();
   echo $task->isDone() ? 'Done' : 'TODO';
}

Modify tasks:

$todos[4]->done();
$todos[5]->addProject('myFancyProject'); 

Write tasks to a file:

$todos->writeToFile(\SplFileInfo("todo.txt"));

Add task:

$task = (new Task("Another task", "F"));
$todos->addTask($task);

Move task within the list (this displaces tasks further down in the list, changing their keys!):

$todos->moveTask($task, 2);

FAQ

Can I use PHPTodoTxt to store tasks in a database?

Absolutely. For now, the easiest way is to use toStringArray() and fromStringArray() and then you have to implement storing and reading to/from the database yourself:

$tasks = readTasksFromDatabase();  // must return an array of strings, one task per line
$todos = TodoTxt::fromStringArray($tasks);
// do whatever with the list
$tasks = $todos->toStringArray();
writeTasksToDatabase($tasks);

License

This code is offered open-source under the GPLv3 license.

tshw/php-todo-txt 适用场景与选型建议

tshw/php-todo-txt 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 20 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 tshw/php-todo-txt 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tshw/php-todo-txt 我们能提供哪些服务?
定制开发 / 二次开发

基于 tshw/php-todo-txt 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2025-06-20