Lightweight user alerts for CodeIgniter 4

v2.1.1 2021-08-31 19:57 UTC

This package is auto-updated.

Last update: 2021-12-01 00:12:46 UTC


Lightweight user alerts for CodeIgniter 4

Coverage Status


Quick Start

  1. Run: > composer require tatter/alerts
  2. Load the helper: helper('alerts');
  3. Set an alert: alert('success', "You did it!")
  4. Add in head tag (optional): <?= service('alerts')->css(); ?>
  5. Add after banner/menu: <?= service('alerts')->display(); ?>


Provides out-of-the-box user alerts for CodeIgniter 4


Install easily via Composer to take advantage of CodeIgniter 4's autoloading capabilities and always be up-to-date:

  • > composer require tatter/alerts

Or, install manually by downloading the source files and adding the directory to app/Config/Autoload.php.

Note: The default display template expects Bootstrap4 but is easily changed.

Configuration (optional)

The library's default behavior can be changed using its config file. Copy examples/Alerts.php to app/Config/Alerts.php and follow the instructions in the comments. If no config file is found the library will use its defaults.


If installed correctly CodeIgniter 4 will detect and autoload the library, service, helper, and config. Initialize the helper if you want the convenience wrapper function: helper('tatter\alerts');

Then use the helper function alert($class, $text) to set an alert for the user's next view. Use class methods $alerts->css() and $alerts->display() to retrieve the styling and HTML for the alerts.


By default alerts will be displayed with classes for Bootstrap (not included). However, styles can be set to use other toolkits (or you may use your own) by changing $template in the config file.