1. Go to this page and download the library: Download scottlaurent/fsrs 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/ */
scottlaurent / fsrs example snippets
use Scottlaurent\FSRS\Manager;
use Scottlaurent\FSRS\Card;
// Create a scheduler with default settings
$fsrs = new Manager();
// Create a new card
$card = new Card(new DateTime('2024-01-01', new DateTimeZone('UTC')));
// Generate scheduling options for different ratings
$schedule = $fsrs->generateRepetitionSchedule($card);
// Choose a rating and get the updated card
// 1 = Again, 2 = Hard, 3 = Good, 4 = Easy
$updatedCard = $schedule[3]->card; // User rated "Good"
echo "Next review: " . $updatedCard->due->format('Y-m-d H:i:s');
echo "Interval: " . $updatedCard->scheduledDays . " days";
$fsrs = new Manager();
$card = new Card(new DateTime('now', new DateTimeZone('UTC')));
// First review
$schedule = $fsrs->generateRepetitionSchedule($card);
$card = $schedule[3]->card; // Good rating
// Subsequent reviews
$reviewDate = new DateTime('2024-01-05', new DateTimeZone('UTC'));
$schedule = $fsrs->generateRepetitionSchedule($card, $reviewDate);
$card = $schedule[2]->card; // Hard rating
new Card(
?DateTime $due = null,
float $stability = 0,
float $difficulty = 0,
int $reps = 0,
int $lapses = 0,
int $state = 0,
?DateTime $lastReview = null,
int $step = 0,
?string $cardId = null
)
// Export card data
$cardData = $card->toArray();
$jsonString = $card->toJson();
// Restore from data
$card = Card::fromArray($cardData);
$card = Card::fromJson($jsonString);
new ReviewLog(
int $rating,
int $scheduledDays,
int $elapsedDays,
DateTime $review,
int $state,
?string $cardId = null,
?DateTime $reviewDateTime = null,
?int $reviewDurationMs = null
)
// Export review log
$logData = $reviewLog->toArray();
$jsonString = $reviewLog->toJson();
// Restore from data
$reviewLog = ReviewLog::fromArray($logData);
$reviewLog = ReviewLog::fromJson($jsonString);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.