PHP code example of sugarcraft / sugar-toast

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

    

sugarcraft / sugar-toast example snippets


use SugarCraft\Toast\{Position, Toast, ToastType};

$toast = Toast::new(50)  // max width 50
    ->withPosition(Position::TopRight)
    ->withDuration(10.0);  // seconds

// Add alerts
$toast = $toast->alert(ToastType::Success, 'File saved!');
$toast = $toast->alert(ToastType::Error, 'Connection failed');

// Render into a viewport
$bg = str_repeat("background content\n", 20);
echo $toast->View($bg);

ToastType::Error
ToastType::Warning
ToastType::Info
ToastType::Success

Position::TopLeft
Position::TopCenter
Position::TopRight
Position::BottomLeft
Position::BottomCenter
Position::BottomRight