wahyudedik/laravel-alert
Composer 安装命令:
composer require wahyudedik/laravel-alert
包简介
A beautiful and easy-to-use alert notification library for Laravel with Blade integration
README 文档
README
A comprehensive Laravel package for managing alerts and notifications with support for multiple themes, animations, and real-time updates.
✨ Features
- Multiple Alert Types - Success, Error, Warning, Info
- Blade Integration - Components and Directives
- Multiple Themes - Bootstrap, Tailwind, Bulma
- Animations - Fade, Slide, Bounce, and more
- Real-time Updates - WebSocket and AJAX support
- Database Storage - Persistent alert storage
- Cache Integration - Redis and Cache support
- REST API - Full API support with authentication
- Admin Panel - Alert management interface
- Performance Optimization - High-performance features
Installation
composer require wahyudedik/laravel-alert
Configuration
Publish the configuration file:
php artisan vendor:publish --provider="Wahyudedik\LaravelAlert\AlertServiceProvider" --tag="laravel-alert-config"
Usage
Using the Facade
use Wahyudedik\LaravelAlert\Facades\Alert; // Success alert Alert::success('Operation completed successfully!'); // Error alert Alert::error('Something went wrong!'); // Warning alert Alert::warning('Please check your input.'); // Info alert Alert::info('Welcome to our application!'); // Custom alert Alert::add('custom', 'This is a custom alert!');
Using Blade Components
<!-- Single alert --> <x-alert type="success" dismissible> Your changes have been saved! </x-alert> <!-- Display all alerts --> <x-alerts />
Using Blade Directives
<!-- Single alert directive --> @alert('info', 'Welcome to our application!') <!-- Display all alerts --> @alerts <!-- Conditional alert --> @alertIf($user->isNew(), 'success', 'Welcome to our platform!')
Configuration Options
// config/laravel-alert.php return [ 'default_theme' => 'bootstrap', // bootstrap, tailwind, bulma 'auto_dismiss' => true, 'dismiss_delay' => 5000, // milliseconds 'animation' => 'fade', // fade, slide, bounce, none 'position' => 'top-right', // top-right, top-left, bottom-right, bottom-left, top-center, bottom-center 'max_alerts' => 5, 'session_key' => 'laravel_alerts', ];
Themes
Bootstrap
<x-alert type="success">Success message</x-alert> <x-alert type="error">Error message</x-alert> <x-alert type="warning">Warning message</x-alert> <x-alert type="info">Info message</x-alert>
Tailwind CSS
<x-alert type="success" class="bg-green-50 text-green-800 border-green-200"> Success message </x-alert>
Advanced Usage
Custom Options
Alert::success('Message', 'Title', [ 'dismissible' => true, 'icon' => 'fas fa-check', 'class' => 'custom-alert-class', 'style' => 'border-left: 4px solid #28a745;' ]);
Custom Themes
You can create custom themes by publishing the views:
php artisan vendor:publish --provider="Wahyudedik\LaravelAlert\AlertServiceProvider" --tag="laravel-alert-views"
Requirements
- PHP 8.0+
- Laravel 9.0+
- Bootstrap 4/5 (for Bootstrap theme)
- Tailwind CSS (for Tailwind theme)
License
MIT License. See LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📚 Documentation
📖 Complete Documentation
For comprehensive documentation, visit our documentation site.
📁 Documentation Structure
docs/
├── README.md # Main documentation index
├── installation.md # Installation guide
├── api.md # API documentation
├── examples.md # Code examples
├── contributing.md # Contributing guide
├── changelog.md # Version history
├── mkdocs.yml # MkDocs configuration
├── package.json # Node.js dependencies
├── requirements.txt # Python dependencies
├── Dockerfile # Docker configuration
├── docker-compose.yml # Docker Compose configuration
├── Makefile # Build automation
└── .gitignore # Git ignore rules
🛠️ Documentation Development
The documentation is built using MkDocs with the Material theme.
Local Development
# Navigate to docs directory cd docs/ # Install dependencies make install # Start development server make dev # Build documentation make build # Deploy to GitHub Pages make deploy
Docker Development
# Start with Docker make docker-dev # Build with Docker make docker-build # Deploy with Docker make docker-deploy
Available Commands
make help # Show all available commands make dev # Start development server make build # Build documentation make deploy # Deploy to GitHub Pages make clean # Clean build files make lint # Lint markdown files make spell # Check spelling make test # Run tests make preview # Preview built documentation
🎯 Key Features
Core Features
- ✅ Multiple Alert Types - Success, Error, Warning, Info
- ✅ Blade Integration - Components and Directives
- ✅ Multiple Themes - Bootstrap, Tailwind, Bulma
- ✅ Animations - Fade, Slide, Bounce, and more
- ✅ Auto-dismiss - Configurable auto-dismissal
- ✅ Session Storage - Built-in session management
Advanced Features
- ✅ Database Storage - Persistent alert storage
- ✅ Cache Integration - Redis and Cache support
- ✅ REST API - Full API support
- ✅ Real-time Updates - WebSocket integration
- ✅ Admin Panel - Alert management interface
- ✅ Performance Optimization - High-performance features
Integration Features
- ✅ Third-party Services - Pusher, WebSocket, Email
- ✅ Authentication - Multiple auth methods
- ✅ Rate Limiting - Built-in rate limiting
- ✅ CORS Support - Cross-origin requests
- ✅ Webhook Support - External integrations
📡 API Usage
# Get all alerts GET /api/v1/alerts # Create alert POST /api/v1/alerts { "type": "success", "message": "Operation completed!", "title": "Success" } # Dismiss alert POST /api/v1/alerts/{id}/dismiss
🧪 Testing
# Run tests composer test # Run with coverage composer test-coverage # Run performance tests composer test-performance
🤝 Contributing
We welcome contributions! Please see our Contributing Guide for details.
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🆘 Support
📊 Statistics
- Version: 1.0.0
- PHP Version: 8.1+
- Laravel Version: 9.0+
- License: MIT
- Stars: ⭐ (GitHub)
- Downloads: 📦 (Packagist)
Made with ❤️ by Wahyudedik
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-24