Files
php-flasher/src/SweetAlert/Prime/README.md
T
Younes ENNAJI 881468ac26 Fix documentation issues: outdated CDN versions, LICENSE years, and broken links
- Update CDN references from @2.2.0 to @2.5.1 in docs/pages/javascript.md
- Fix LICENSE badge link in README.md to point to correct repo (php-flasher/php-flasher)
- Update copyright year to 2024-present across all 16 LICENSE files
- Fix docs/package.json version from 2.1.0 to 2.5.1
- Update sub-package READMEs to reference PHPFlasher ^2.5.1
- Add docs/package.json to bin/bump update targets
- Remove commented-out dead code in ResponseExtension.php
2026-03-29 23:07:04 +01:00

2.2 KiB

PHPFlasher SweetAlert Adapter (Prime)

Latest Version Total Downloads License

SweetAlert2 adapter for PHPFlasher. Beautiful alert dialogs with modal and toast support.

Requirements

  • PHP >= 8.2
  • PHPFlasher ^2.5.1

Installation

composer require php-flasher/flasher-sweetalert

Quick Start

// Basic usage
sweetalert('Operation completed successfully!', 'success');
sweetalert('An error occurred.', 'error');
sweetalert('Information message.', 'info');
sweetalert('Warning message.', 'warning');

// With options
sweetalert('Success message', 'success', [
    'timer' => 3000,
    'toast' => true,
    'position' => 'top-end',
]);

// Modal dialog with options
sweetalert('Profile updated!', 'success', [
    'confirmButtonText' => 'Great!',
    'timer' => 5000,
]);

Features

  • Simple API: success(), error(), info(), warning(), flash()
  • SweetAlert2 Options: timer, toast, position, showConfirmButton, showCancelButton
  • Modal Support: Full SweetAlert2 modal dialogs and toasts
  • Type Safety: Full PHP type hints and PHPStan support
  • Helper Functions: Global sweetalert() helper for quick access

Available Methods

// Success notification
sweetalert($message, 'success', $options, $title);

// Error notification
sweetalert($message, 'error', $options, $title);

// Info notification
sweetalert($message, 'info', $options, $title);

// Warning notification
sweetalert($message, 'warning', $options, $title);

// Custom notification type
sweetalert($message, $type, $options, $title);

// With options
sweetalert($message, 'success', [
    'timer' => 3000,
    'toast' => true,
    'position' => 'top-end',
], $title);

Documentation

Complete documentation: php-flasher.io

License

MIT