PHP code example of codebar-ag / laravel-miro

1. Go to this page and download the library: Download codebar-ag/laravel-miro 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/ */

    

codebar-ag / laravel-miro example snippets


use CodebarAg\Miro\Facades\Miro;

$response = Miro::getBoard('board_id');

$response->successful();  // bool
$response->failed();      // bool
$response->status();      // int    (e.g. 200, 404, 429)
$response->error();       // ?string — null on success
$response->errorCode();   // ?string — null on success
$response->dto();         // typed DTO or array of DTOs, null on failure

$response = Miro::getBoard('board_id');

if ($response->successful()) {
    $board = $response->dto(); // BoardDto
} else {
    $response->status();     // e.g. 404
    $response->error();      // e.g. "Board not found"
    $response->errorCode();  // e.g. "board_not_found"
}

use CodebarAg\Miro\Facades\Miro;
use CodebarAg\Miro\Dto\Boards\CreateBoardDto;
use CodebarAg\Miro\Dto\Boards\GetBoardsDto;
use CodebarAg\Miro\Dto\Boards\UpdateBoardDto;

/**
 * Get All Boards
 */
$response = Miro::getBoards();
$boards = $response->dto(); // BoardDto[]

/**
 * Get Boards With Filters
 */
$response = Miro::getBoards(new GetBoardsDto(
    teamId: 'team_123',
    limit: 10,
));

/**
 * Get A Board
 */
$response = Miro::getBoard('board_id');
$board = $response->dto(); // BoardDto

/**
 * Create A Board
 */
$response = Miro::createBoard(new CreateBoardDto(
    name: 'My Sprint Board',
    description: 'Q1 planning board',
));
$board = $response->dto(); // BoardDto

/**
 * Update A Board
 */
$response = Miro::updateBoard('board_id', new UpdateBoardDto(
    name: 'Q1 Planning',
));
$board = $response->dto(); // BoardDto

/**
 * Delete A Board
 */
Miro::deleteBoard('board_id'); // returns Saloon\Http\Response

use CodebarAg\Miro\Facades\Miro;
use CodebarAg\Miro\Dto\BoardItems\GetBoardItemsDto;

/**
 * Get All Items On A Board
 */
$response = Miro::getBoardItems('board_id');
$items = $response->dto(); // BoardItemDto[]

/**
 * Get Items Filtered By Type
 */
$response = Miro::getBoardItems('board_id', new GetBoardItemsDto(
    type: 'sticky_note',
));

/**
 * Get A Board Item
 */
$response = Miro::getBoardItem('board_id', 'item_id');
$item = $response->dto(); // BoardItemDto

use CodebarAg\Miro\Facades\Miro;
use CodebarAg\Miro\Dto\StickyNotes\CreateStickyNoteDto;
use CodebarAg\Miro\Dto\StickyNotes\GetStickyNotesDto;
use CodebarAg\Miro\Dto\StickyNotes\UpdateStickyNoteDto;

/**
 * Get All Sticky Notes On A Board
 */
$response = Miro::getStickyNotes('board_id');
$notes = $response->dto(); // StickyNoteDto[]

/**
 * Get A Sticky Note
 */
$response = Miro::getStickyNote('board_id', 'item_id');
$note = $response->dto(); // StickyNoteDto

/**
 * Create A Sticky Note
 */
$response = Miro::createStickyNote('board_id', new CreateStickyNoteDto(
    content: 'Hello World',
    shape: 'square',
    fillColor: 'yellow',
    positionX: 100.0,
    positionY: 200.0,
));
$note = $response->dto(); // StickyNoteDto

/**
 * Update A Sticky Note
 */
$response = Miro::updateStickyNote('board_id', 'item_id', new UpdateStickyNoteDto(
    content: 'Updated content',
));
$note = $response->dto(); // StickyNoteDto

/**
 * Delete A Sticky Note
 */
Miro::deleteStickyNote('board_id', 'item_id'); // returns Saloon\Http\Response

use CodebarAg\Miro\Facades\Miro;
use CodebarAg\Miro\Dto\Frames\CreateFrameDto;
use CodebarAg\Miro\Dto\Frames\GetFramesDto;
use CodebarAg\Miro\Dto\Frames\UpdateFrameDto;

/**
 * Get All Frames On A Board
 */
$response = Miro::getFrames('board_id');
$frames = $response->dto(); // FrameDto[]

/**
 * Get A Frame
 */
$response = Miro::getFrame('board_id', 'item_id');
$frame = $response->dto(); // FrameDto

/**
 * Create A Frame
 */
$response = Miro::createFrame('board_id', new CreateFrameDto(
    title: 'Sprint 1',
    positionX: 0.0,
    positionY: 0.0,
    width: 1920.0,
    height: 1080.0,
));
$frame = $response->dto(); // FrameDto

/**
 * Update A Frame
 */
$response = Miro::updateFrame('board_id', 'item_id', new UpdateFrameDto(
    title: 'Sprint 1 – Updated',
));
$frame = $response->dto(); // FrameDto

/**
 * Delete A Frame
 */
Miro::deleteFrame('board_id', 'item_id'); // returns Saloon\Http\Response
bash
php artisan vendor:publish --tag="laravel-miro-config"
bash
php artisan boost:install