PHP code example of degordian / roomfinder

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

    

degordian / roomfinder example snippets


$roomResourceAdapter = new RoomResourceGoogleCalendar();
$roomResourceAdapter->setConfig([
    'applicationName' => 'FindARoom',
    'credentialsPath' => '/Users/tonymrakovcic/credentials/calendar-findaroom.json',
    'clientSecretPath' => '/Users/tonymrakovcic/credentials/client_secret.json',
    'scopes' => [\Google_Service_Calendar::CALENDAR],
    'accessType' => 'offline',
])->init();


$roomHandler = new RoomHandler();
$roomHandler->setRoomResourceAdapter($roomResourceAdapter);

$rooms  = [
    [
        'name' => 'Meeting room one',
        'id' => '[email protected]',
        'size' => Room::SIZE_BIG,
        'resourceClass' => RoomResourceGoogleCalendar::class,
    ],
    [
        'name' => 'Meeting room two',
        'id' => '[email protected]',
        'size' => Room::SIZE_MEDIUM,
        'resourceClass' => RoomResourceGoogleCalendar::class,
    ]
];

$roomHandler->addRooms($rooms);

$roomsAvailable = $roomHandler->getAllRoomsAvailability();

$availableRoomNow = $roomHandler->findAvailableRoom(RoomHandler::HOUR);

$roomsAvailable = $roomHandler->findAvailableBigRoom();

$reservation = $roomHandler->reserveRoom($roomsAvailable[0]);

   php examples/auth.php