PHPackages                             michalsn/codeigniter-htmx-alerts - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. michalsn/codeigniter-htmx-alerts

ActiveLibrary

michalsn/codeigniter-htmx-alerts
================================

Alerts for working with CodeIgniter 4 framework

47.7k↓50%1PHPCI passing

Since Dec 15Pushed 5mo ago2 watchersCompare

[ Source](https://github.com/michalsn/codeigniter-htmx-alerts)[ Packagist](https://packagist.org/packages/michalsn/codeigniter-htmx-alerts)[ RSS](/packages/michalsn-codeigniter-htmx-alerts/feed)WikiDiscussions develop Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

CodeIgniter Htmx Alerts
=======================

[](#codeigniter-htmx-alerts)

A simple Alerts class integrated with [htmx](https://htmx.org) and [Alpine.js](https://alpinejs.dev) for CodeIgniter 4 framework.

[![PHPUnit](https://github.com/michalsn/codeigniter-htmx-alerts/actions/workflows/phpunit.yml/badge.svg)](https://github.com/michalsn/codeigniter-htmx-alerts/actions/workflows/phpunit.yml)[![PHPStan](https://github.com/michalsn/codeigniter-htmx-alerts/actions/workflows/phpstan.yml/badge.svg)](https://github.com/michalsn/codeigniter-htmx-alerts/actions/workflows/phpstan.yml)[![Deptrac](https://github.com/michalsn/codeigniter-htmx-alerts/actions/workflows/deptrac.yml/badge.svg)](https://github.com/michalsn/codeigniter-htmx-alerts/actions/workflows/deptrac.yml)[![Coverage Status](https://camo.githubusercontent.com/5c9055c8db039adad749001cf5ed70526c9de3da8575910fea38eaff987f8aee/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d696368616c736e2f636f646569676e697465722d68746d782d616c657274732f62616467652e7376673f6272616e63683d646576656c6f70)](https://coveralls.io/github/michalsn/codeigniter-htmx-alerts?branch=develop)

[![PHP](https://camo.githubusercontent.com/d6aac44f81cb2e6f4e71f098a1cb4a71992f24f7bfb424f6670db8313c9a855c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e312d626c7565)](https://camo.githubusercontent.com/d6aac44f81cb2e6f4e71f098a1cb4a71992f24f7bfb424f6670db8313c9a855c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e312d626c7565)[![CodeIgniter](https://camo.githubusercontent.com/8867c0cb2bfb4e11f527658f45d11bea936efb5a06e66b10e576912cf40874e5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f646549676e697465722d253545342e332d626c7565)](https://camo.githubusercontent.com/8867c0cb2bfb4e11f527658f45d11bea936efb5a06e66b10e576912cf40874e5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f436f646549676e697465722d253545342e332d626c7565)

Installation
------------

[](#installation)

```
composer require michalsn/codeigniter-htmx-alerts:dev-develop

```

Configuration
-------------

[](#configuration)

You have to publish the config file first:

```
php spark alerts:publish

```

Now you can change:

#### $key

[](#key)

Alerts key name used in views and session.

#### $displayTime

[](#displaytime)

The default alert display time in milliseconds.

#### $types

[](#types)

The array of message types, where array key is a CSS class and value is the title of the alert type.

Array keys are also used to determine the type of the alert we want to set, ie:

```
alerts()->set('success', 'Success message goes here.');
```

#### $htmlWrapperId

[](#htmlwrapperid)

Wrapper `id` name, used in the view file.

#### $views

[](#views)

View files used by this library. You can change them to reflect the current style/theme you're using.

The default view files are designed to play along with [Tabler](https://tabler.io/admin-template) theme.

Usage
-----

[](#usage)

In your main layout place the code (usually it will be just before the closing `` tag):

```

```

Don't forget to include these scripts in your main layout for proper functionality:

```

```

That's it. You're ready to go. No matter if this is a `htmx` request or traditional one, your alerts will be placed correctly every time.

#### Adding alerts

[](#adding-alerts)

You can add alerts in your controllers.

```
// success alert
alerts()->set('success', 'Success message');
// error message
alerts()->set('danger', 'Error message');
// custom display time - 1 sec (in milliseconds)
alerts()->set('success', 'Message', 1000);
```

#### Custom Alert Title

[](#custom-alert-title)

With the new method `withTitle()`, you can set a custom title for your alerts.

```
// success alert with a custom title
alerts()->withTitle('Custom Title')->set('success', 'Success message');
// error alert with a custom title
alerts()->withTitle('Oops!')->set('danger', 'Error message');
```

You can also configure whether the Custom Alert Title should be reset after each `set()` call by passing a second parameter:

```
// success alert with a custom title that will not reset after each set
alerts()->withTitle('Custom Title', false)->set('success', 'Success Message One');
alerts()->set('success', 'Success Message Two');
```

#### Removing alerts

[](#removing-alerts)

You can also remove alerts by type.

```
// will remove all success alerts
alerts()->clear('success');
// will remove all alerts
alerts()->clear();
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance50

Moderate activity, may be stable

Popularity29

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

Top contributor holds 76.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/459185?v=4)[Michal Sniatala](/maintainers/michalsn)[@michalsn](https://github.com/michalsn)

---

Top Contributors

[![michalsn](https://avatars.githubusercontent.com/u/459185?v=4)](https://github.com/michalsn "michalsn (16 commits)")[![datamweb](https://avatars.githubusercontent.com/u/9530214?v=4)](https://github.com/datamweb "datamweb (4 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

alpinejscodeignitercodeigniter4htmx

### Embed Badge

![Health badge](/badges/michalsn-codeigniter-htmx-alerts/health.svg)

```
[![Health](https://phpackages.com/badges/michalsn-codeigniter-htmx-alerts/health.svg)](https://phpackages.com/packages/michalsn-codeigniter-htmx-alerts)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
