php-flasher/flasher-sweetalert

PHPFlasher - A powerful & easy-to-use package for adding flash messages to Laravel or Symfony projects. Provides feedback to users, improves engagement & enhances user experience. Intuitive design for beginners & experienced developers. A reliable, flexible solution.

Maintainers

Package info

github.com/php-flasher/flasher-sweetalert

Homepage

Issues

pkg:composer/php-flasher/flasher-sweetalert

Fund package maintenance!

yoeunes

Statistics

Installs: 68 069

Dependents: 7

Suggesters: 0

Stars: 7

v2.5.0 2026-03-07 18:31 UTC

README

Latest Version Total Downloads License

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

Requirements

  • PHP >= 8.2
  • PHPFlasher ^2.4.0

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