amjadiqbal/alertify

A BEAUTIFUL, RESPONSIVE, CUSTOMIZABLE, ACCESSIBLE (WAI-ARIA) REPLACEMENT FOR JAVASCRIPT'S POPUP BOXES , AVAILABLE FOR LARAVEL PROJECTS.

dev-master 2025-07-17 19:17 UTC

This package is auto-updated.

Last update: 2025-07-17 19:22:18 UTC


README

A beautiful, responsive, customizable, accessible (WAI-ARIA) replacement for JavaScript's popup boxes, available for Laravel projects.

Latest Stable Version Total Downloads License

Introduction

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.

Features

  • 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

Installation

Step 1: Install the package via Composer

composer require amjadiqbal/alertify

Step 2: Register the Service Provider (Laravel 5.4 or below)

For 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,
],

Step 3: Publish the assets

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/

Configuration

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'     => '',
    ]
];

Usage

Basic Usage

// 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
]);

Using with Controllers

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();
}

Using the Middleware

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');

Including in Blade Templates

Make sure to include the Alertify scripts in your Blade templates:

@include('alertify::alert')

Available Alert Types

  • success
  • error
  • warning
  • info
  • question

Customization

You can customize the appearance and behavior of alerts by modifying the configuration or passing custom options when calling the alert() function.

Support

If you encounter any issues or have questions, please feel free to create an issue on the GitHub repository.

License

The Alertify package is open-sourced software licensed under the MIT license.

Credits