PHP code example of marioquartz / making-sessions

1. Go to this page and download the library: Download marioquartz/making-sessions 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/ */

    

marioquartz / making-sessions example snippets


use Marioquartz\MakingSessions\Maker;
use Marioquartz\MakingSessions\Event;

$maker=new Maker();
foreach ($list as $item) {
    $event=new Event();
    $event
        ->setStart($start) //start can be a timestamp or a DateInmutable
        ->setDuration(60) // you can set the duration or use setEnd()
        ->setType("example");
    $maker->add($event);
}

$sessions=$maker->getSessions();

foreach($sessions as $session) {
    echo $session->getStart(); // Start of the session returned as timestamp
    echo $session->getEnd(); //End as timestamp
    echo $session->getDuration() // Duration in seconds
    echo $session->getType(); // Type of the events inside
    foreach ($session->getEvents() as $event) {
        //events have the same functions: getStart(), getEnd(), getDuration() and getType()
    }
}