A beautiful, responsive, customizable, accessible (WAI-ARIA) replacement for JavaScript's popup boxes, available for Laravel projects.
Alertify is a Laravel package that integrates the AlertifyJS library to provide beautiful, customizable alert and notification boxes for your Laravel applications. It offers a simple and elegant way to replace JavaScript's default popup boxes with more stylish and functional alternatives.
- Beautiful, responsive alert dialogs
- Toast notifications
- Customizable themes and styles
- WAI-ARIA accessibility support
- Simple integration with Laravel
- Middleware support for automatic alerts
- Session-based alert management
composer require amjadiqbal/alertifyFor Laravel 5.5 and above, the package will be auto-discovered. For older versions, add the service provider to your config/app.php file:
'providers' => [
// ...
AmjadIqbal\Alertify\Providers\AlertifyServiceProvider::class,
],php artisan vendor:publish --provider="AmjadIqbal\Alertify\Providers\AlertifyServiceProvider"This will publish:
- Configuration file to
config/alertify.php - JavaScript assets to
public/alertify/ - Views to
resources/views/vendor/alertify/
After publishing the configuration file, you can customize the default settings in config/alertify.php:
return [
'default' => [
'title' => [],
'text' => [],
'timer' => env('ALERTIFY_TIMER'),
'width' => env('ALERTIFY_WIDTH'),
'heightAuto' => env('ALERTIFY_HEIGHT_AUTO'),
'padding' => env('ALERTIFY_PADDING'),
'animation' => env('ALERTIFY_ANIMATION'),
'showConfirmButton' => env('ALERTIFY_SHOW_CONFIRM_BUTTON'),
'showCloseButton' => env('ALERTIFY_CLOSE_BUTTON'),
],
'middleware' => [
'title' => '',
'text' => '',
'type' => '',
'html' => '',
'toast' => '',
'position' => '',
'width' => '',
'showConfirmButton' => '',
'showCloseButton' => '',
]
];// Display a simple alert
alert(['title' => 'Hello!', 'text' => 'Welcome to Alertify', 'type' => 'success']);
// Display an alert with more options
alert([
'title' => 'Oops...',
'text' => 'Something went wrong!',
'type' => 'error',
'timer' => 3000,
'showCloseButton' => true
]);public function store(Request $request)
{
// Process the request...
// Display a success message
alert([
'title' => 'Success!',
'text' => 'Your data has been saved.',
'type' => 'success'
]);
return redirect()->back();
}You can use the included middleware to automatically display alerts based on session data. Add the middleware to your app/Http/Kernel.php file:
protected $middlewareGroups = [
'web' => [
// ...
\AmjadIqbal\Alertify\Core\Alertify::class,
],
];Then, you can flash alert data to the session:
$request->session()->flash('title', 'Success!');
$request->session()->flash('text', 'Operation completed successfully.');
$request->session()->flash('type', 'success');Make sure to include the Alertify scripts in your Blade templates:
@include('alertify::alert')successerrorwarninginfoquestion
You can customize the appearance and behavior of alerts by modifying the configuration or passing custom options when calling the alert() function.
If you encounter any issues or have questions, please feel free to create an issue on the GitHub repository.
The Alertify package is open-sourced software licensed under the MIT license.