PHP code example of phil / spaced-repetition

1. Go to this page and download the library: Download phil/spaced-repetition 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/ */

    

phil / spaced-repetition example snippets


use Phil\SpacedRepetition\Card;
use Phil\SpacedRepetition\Rating;
use Phil\SpacedRepetition\Scheduler;

$scheduler = new Scheduler();
$now = new DateTimeImmutable();

$card = Card::new('deck-3/card-42', $now);
$outcome = $scheduler->review($card, Rating::Good, $now);

$outcome->card->due;          // ten minutes from now: the second learning step
$outcome->card->state;        // CardState::Learning
$outcome->log;                // the review, to keep for replays and optimisers

foreach ($scheduler->preview($outcome->card, $outcome->card->due) as $rating => $next) {
    echo $rating, ': ', $next->waitSeconds(), ' s', PHP_EOL;   // the wait each button would give
}