{"id":15275890,"url":"https://github.com/michalsn/codeigniter-htmx-alerts","last_synced_at":"2025-04-12T14:02:26.382Z","repository":{"id":257801736,"uuid":"855588828","full_name":"michalsn/codeigniter-htmx-alerts","owner":"michalsn","description":"A simple Alerts class integrated with htmx and Alpine.js for CodeIgniter 4 framework.","archived":false,"fork":false,"pushed_at":"2024-10-21T05:35:30.000Z","size":37,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-02-16T15:51:10.250Z","etag":null,"topics":["alpinejs","codeigniter","codeigniter4","htmx"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michalsn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-11T05:54:39.000Z","updated_at":"2024-10-21T05:35:28.000Z","dependencies_parsed_at":"2024-10-21T08:17:39.384Z","dependency_job_id":"9dac6bcd-6818-4a07-abb9-aebf9deb1b37","html_url":"https://github.com/michalsn/codeigniter-htmx-alerts","commit_stats":null,"previous_names":["michalsn/codeigniter-htmx-alerts"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michalsn%2Fcodeigniter-htmx-alerts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michalsn%2Fcodeigniter-htmx-alerts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michalsn%2Fcodeigniter-htmx-alerts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michalsn%2Fcodeigniter-htmx-alerts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michalsn","download_url":"https://codeload.github.com/michalsn/codeigniter-htmx-alerts/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239938059,"owners_count":19721560,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alpinejs","codeigniter","codeigniter4","htmx"],"created_at":"2024-09-30T11:00:25.433Z","updated_at":"2025-04-12T14:02:26.376Z","avatar_url":"https://github.com/michalsn.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CodeIgniter Htmx Alerts\n\nA simple Alerts class integrated with [htmx](https://htmx.org) and [Alpine.js](https://alpinejs.dev) for CodeIgniter 4 framework.\n\n[![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)\n[![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)\n[![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)\n[![Coverage Status](https://coveralls.io/repos/github/michalsn/codeigniter-htmx-alerts/badge.svg?branch=develop)](https://coveralls.io/github/michalsn/codeigniter-htmx-alerts?branch=develop)\n\n![PHP](https://img.shields.io/badge/PHP-%5E8.1-blue)\n![CodeIgniter](https://img.shields.io/badge/CodeIgniter-%5E4.3-blue)\n\n## Installation\n\n    composer require michalsn/codeigniter-htmx-alerts:dev-develop\n\n## Configuration\n\nYou have to publish the config file first:\n\n    php spark alerts:publish\n\nNow you can change:\n\n#### $key\n\nAlerts key name used in views and session.\n\n#### $displayTime\n\nThe default alert display time in milliseconds.\n\n#### $types\n\nThe array of message types, where array key is a CSS class and value is the title of the alert type.\n\nArray keys are also used to determine the type of the alert we want to set, ie:\n\n```php\nalerts()-\u003eset('success', 'Success message goes here.');\n```\n\n#### $htmlWrapperId\n\nWrapper `id` name, used in the view file.\n\n#### $views\n\nView files used by this library. You can change them to reflect the current style/theme you're using.\n\nThe default view files are designed to play along with [Tabler](https://tabler.io/admin-template) theme.\n\n## Usage\n\nIn your main layout place the code (usually it will be just before the closing `\u003c/body\u003e` tag):\n\n```php\n\u003c?= alerts()-\u003econtainer(); ?\u003e\n```\n\nDon't forget to include these scripts in your main layout for proper functionality:\n```html\n\u003cscript src=\"https://unpkg.com/htmx.org@2.0.4\"\u003e\u003c/script\u003e\n\u003cscript src=\"//unpkg.com/alpinejs\" defer\u003e\u003c/script\u003e\n```\n\nThat'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.\n\n#### Adding alerts\n\nYou can add alerts in your controllers.\n\n```php\n// success alert\nalerts()-\u003eset('success', 'Success message');\n// error message\nalerts()-\u003eset('danger', 'Error message');\n// custom display time - 1 sec (in milliseconds)\nalerts()-\u003eset('success', 'Message', 1000);\n```\n#### Custom Alert Title\n\nWith the new method `withTitle()`, you can set a custom title for your alerts.\n\n```php\n// success alert with a custom title\nalerts()-\u003ewithTitle('Custom Title')-\u003eset('success', 'Success message');\n// error alert with a custom title\nalerts()-\u003ewithTitle('Oops!')-\u003eset('danger', 'Error message');\n\n```\n\nYou can also configure whether the Custom Alert Title should be reset after each `set()` call by passing a second parameter:\n\n```php\n// success alert with a custom title that will not reset after each set\nalerts()-\u003ewithTitle('Custom Title', false)-\u003eset('success', 'Success Message One');\nalerts()-\u003eset('success', 'Success Message Two');\n```\n\n#### Removing alerts\n\nYou can also remove alerts by type.\n\n```php\n// will remove all success alerts\nalerts()-\u003eclear('success');\n// will remove all alerts\nalerts()-\u003eclear();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichalsn%2Fcodeigniter-htmx-alerts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichalsn%2Fcodeigniter-htmx-alerts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichalsn%2Fcodeigniter-htmx-alerts/lists"}