PHP code example of tilttek / writing-goals

1. Go to this page and download the library: Download tilttek/writing-goals 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/ */

    

tilttek / writing-goals example snippets


use Phil\Resource\ResourceReference;
use Symfony\Component\Clock\Clock;
use Tilttek\WritingGoals\{Curve, Day, Goal, WritingDays, WritingGoals};
use Tilttek\WritingGoals\Store\{InMemoryGoalStore, InMemoryLogStore};

$goals = new WritingGoals(new InMemoryGoalStore(), new InMemoryLogStore(), new Clock(), $dispatcher);

$goals->save(new Goal(
    'novel-2026',
    ResourceReference::of('member', '44'),
    50_000,
    Day::fromString('2026-11-01'),
    Day::fromString('2026-11-30'),
    curve: Curve::frontLoaded(),
    writingDays: WritingDays::on(1, 2, 3, 4, 5, 6),
    timezone: 'America/Montreal',
));

$plan = $goals->log('novel-2026', 1_200);
$plan->todayQuota;   // what today asks for
$plan->leftToday();  // what is left of it
$plan->remaining();  // what is left of the target