PHP code example of yannxtrem / grsu-timetable

1. Go to this page and download the library: Download yannxtrem/grsu-timetable 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/ */

    

yannxtrem / grsu-timetable example snippets


use Yannxtrem\GrsuTimetable\GrsuTimetable;

$timetable = new GrsuTimetable();

// Fetch schedule for a specific date
$week = $timetable->forDate('2026-04-22');

if ($week !== null) {
    echo "Group: " . $week->groupName . "\n";
    echo "Week: " . $week->weekNumber . "\n";

    foreach ($week->days as $day) {
        echo "Day: " . $day->weekday . " / " . $day->monthday . "\n";
        foreach ($day->classes as $class) {
            echo "  " . $class->time->start->format('H:i') . " - " . $class->time->end->format('H:i');
            echo "  " . $class->subject->name;
            echo "  (" . $class->subgroup . ")";
            if ($class->door !== null) {
                echo "  Room: " . $class->door;
            }
            echo "\n";
        }
    }
}

use Yannxtrem\GrsuTimetable\GrsuTimetable;

// Via DI
$week = app(GrsuTimetable::class)->forDate(now());

// Via alias
$week = app('grsu-timetable')->forDate(now(), ['arg0' => '12345']);

$week = $timetable->forDate('2026-04-22');

// With a DateTime object
$week = $timetable->forDate(new DateTimeImmutable('2026-04-22'));

// Override group parameters
$week = $timetable->forDate('2026-04-22', [
    'arg0' => '12345',
    'arg1' => '3',
    'arg2' => '2',
    'arg3' => '1',
    'arg4' => '1',
]);

// Force refresh (bypass cache)
$week = $timetable->forDate('2026-04-22', forceRefresh: true);

// Skip scraping if not cached
$week = $timetable->forDate('2026-04-22', scrapeIfMissing: false);

$week = $timetable->getByGroup('СДП-УИР-251', 2);

// With a known URL for scraping on cache miss
$week = $timetable->getByGroup('СДП-УИР-251', 2, url: 'https://raspisanie.grsu.by/...');

$week = $timetable->scrapeUrl('https://raspisanie.grsu.by/TimeTable/PrintPage.aspx?arg0=18156&...');

// List all cached URLs
$urls = $timetable->cachedUrls();

// Clear all managed cache entries
$timetable->clearCache();

// Swap the cache store at runtime
use Yannxtrem\GrsuTimetable\Cache\LaravelCacheStore;
$timetable->setCache(new LaravelCacheStore($laravelCache));

return [
    // Default group identifiers for raspisanie.grsu.by
    'default_group_params' => [
        'arg0' => '18156',  // Main group ID
        'arg1' => '3',
        'arg2' => '2',      // Week number
        'arg3' => '1',
        'arg4' => '1',
    ],

    // Cache TTL in seconds (default: 1 hour)
    'cache_ttl' => 3600,

    'cache' => [
        'enabled' => true,   // false = use the package's in-memory cache
        'store' => null,     // null = Laravel's default cache store
    ],
];
bash
php artisan vendor:publish --tag=grsu-timetable-config
bash
php artisan vendor:publish --tag=grsu-timetable-config