Files
php-flasher/docs/pages/javascript.md
T
Younes ENNAJI 881468ac26 Fix documentation issues: outdated CDN versions, LICENSE years, and broken links
- Update CDN references from @2.2.0 to @2.5.1 in docs/pages/javascript.md
- Fix LICENSE badge link in README.md to point to correct repo (php-flasher/php-flasher)
- Update copyright year to 2024-present across all 16 LICENSE files
- Fix docs/package.json version from 2.1.0 to 2.5.1
- Update sub-package READMEs to reference PHPFlasher ^2.5.1
- Add docs/package.json to bin/bump update targets
- Remove commented-out dead code in ResponseExtension.php
2026-03-29 23:07:04 +01:00

3.6 KiB

permalink, redirect_from, title, description
permalink redirect_from title description
/javascript/ /docs/framework/javascript/ JavaScript Easily add flash notification messages to your JavaScript application with PHPFlasher. Follow our step-by-step guide to install the library using npm or include it in your project using CDN links, and start engaging and informing your users with powerful flash messages.

PHPFlasher assets can be installed from a CDN or using npm

Installation

Quick start guide for installing the PHPFlasher from cdn or npm.


cdn

To pull in the PHPFlasher via CDN, grab the latest version from jsdelivr

cdn-jsdelivr
<script defer src="https://cdn.jsdelivr.net/npm/@flasher/flasher@2.5.1/dist/flasher.min.js"></script>

npm

To install PHPFlasher from npm use the following command:

npm i @flasher/flasher

Usage

import flasher from "@flasher/flasher";

window.flasher = flasher; // only if you want to use it globally

flasher.error("Oops! Something went wrong!");
flasher.warning("Are you sure you want to proceed ?");
flasher.success("Data has been saved successfully!");
flasher.info("Welcome back");

or if you are using a cdn like this:

<script defer src="https://cdn.jsdelivr.net/npm/@flasher/flasher@2.5.1/dist/flasher.min.js"></script>
<script>
    flasher.error("Oops! Something went wrong!");
    flasher.warning("Are you sure you want to proceed ?");
    flasher.success("Data has been saved successfully!");
    flasher.info("Welcome back");
</script>

Other adapters

First grab the CDN for any js library adapter supported by PHPFlasher or install it with npm and then call the create() method on flasher object :

<script defer src="https://cdn.jsdelivr.net/npm/@flasher/flasher@2.5.1/dist/flasher.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/@flasher/flasher-toastr@2.5.1/dist/flasher-toastr.min.js"></script>
<script>
    const factory = flasher.use('toastr');
    factory.error("Oops! Something went wrong!");
    factory.warning("Are you sure you want to proceed ?");
    factory.success("Data has been saved successfully!");
    factory.info("Welcome back");
    
    // or simply with
    flasher.toastr.error("Oops! Something went wrong!");
    flasher.toastr.warning("Are you sure you want to proceed ?");
    flasher.toastr.success("Data has been saved successfully!");
    flasher.toastr.info("Welcome back");
</script>