Compare commits

...

83 Commits

Author SHA1 Message Date
Younes ENNAJI aee6d2764a Merge pull request #216 from php-flasher/v2.1.5
prepare for v2.1.5
2025-02-21 18:55:10 +01:00
Younes ENNAJI a26cac3a07 prepare for v2.1.5 2025-02-21 18:52:39 +01:00
Younes ENNAJI 811fc1a5eb Merge pull request #215 from php-flasher/v2.1.4
chore: bump flasher dependency to v2.1.4
2025-02-18 14:02:26 +01:00
Younes ENNAJI 1b3b0bd08f add support for laravel v12 2025-02-18 14:01:24 +01:00
Younes ENNAJI 7972fd2d46 chore: bump flasher dependency to v2.1.4 2025-02-18 13:58:18 +01:00
Younes ENNAJI 31e2725566 Merge pull request #214 from php-flasher/issues/213
Fix PHPStan issue by removing includes section from composer.json
2025-02-18 13:54:49 +01:00
Younes ENNAJI b31695ff58 Remove phpstan includes section from composer.json 2025-02-18 13:51:41 +01:00
Younes ENNAJI a314692534 update assets version in package.json to v2.1.3 2025-01-25 14:59:20 +01:00
Younes ENNAJI 9de126bb55 update CHANGELOG 2025-01-25 14:38:48 +01:00
Younes ENNAJI f66382e324 Merge pull request #211 from ToshY/feature/208
Add GitHub workflow for automatic publishing of assets to NPM
2025-01-25 14:31:49 +01:00
ToshY e2ef4f08a4 add workflow for automatic publishing of assets to NPM 2025-01-23 00:24:45 +01:00
Younes ENNAJI 1e1b70e59b docs: upgrade dependencies and build assets 2025-01-19 18:50:40 +01:00
Younes ENNAJI 0ca4b5c197 Merge pull request #210 from php-flasher/upgrade-dependencies
upgrade dependencies
2025-01-18 11:34:10 +01:00
Younes ENNAJI df8eb83abe chore: update CHANGELOG 2025-01-18 11:30:44 +01:00
Younes ENNAJI 3f1b22a126 chore: bump flasher dependency to v2.1.2 2025-01-18 11:26:31 +01:00
Younes ENNAJI b11524c2f9 update demo files 2025-01-18 11:23:18 +01:00
Younes ENNAJI a2333762ea build documentation 2025-01-18 11:23:18 +01:00
Younes ENNAJI 3e2e853022 upgrade dependencies 2025-01-18 11:23:17 +01:00
Younes ENNAJI 27904be912 Merge pull request #209 from php-flasher/issues/208
feat: make mainScript nullable
2025-01-18 11:22:59 +01:00
Younes ENNAJI c9d3b56346 feat: make mainScript nullable 2025-01-17 10:28:13 +01:00
Younes ENNAJI db485d1ff2 Merge pull request #207 from BrookeDot/patch-2
Update Flasher Class Parameter Order
2024-11-09 00:38:24 +01:00
Brooke. 707c7a42e1 Update Flasher Class Parameter Order
The order of `$title` and `$options` has changed, if one tries to pass a string to parameter three ($options) an error is thrown. This updates the docs accordingly.

Looks like the order was changed here:
https://github.com/php-flasher/php-flasher/blob/2.x/src/Prime/helpers.php#L21-L36
2024-11-08 13:33:52 -08:00
Younes ENNAJI 456016a585 docs: update contributors list 2024-11-06 22:52:07 +01:00
Younes ENNAJI a38ddbb53a Merge pull request #206 from BrookeDot/patch-1
Fix 404s and add links to new Guides to Getting Started
2024-11-06 22:43:03 +01:00
Brooke. 5a73173dcf Fix 404s and add links to new Guides to Getting Started
Fixes the 404s for Laravel and Symfony links (due to case sensitivity) and adds the Livewire and Inertia guides to the Getting Started section
2024-11-06 13:23:50 -08:00
Younes ENNAJI 7abdccf284 Add PR template and auto-close PR on subtree split repositories 2024-10-27 16:04:49 +01:00
Younes ENNAJI a34a943397 docs: update laravel README.md add preset example 2024-10-27 15:31:54 +01:00
Younes ENNAJI fe4601bb8b docs: update symfony README.md file 2024-10-27 15:29:49 +01:00
Younes ENNAJI 86a56f4cff docs: update laravel markdown file 2024-10-27 15:02:54 +01:00
Younes ENNAJI c3493a7335 docs: update header links inside of README.md file 2024-10-27 14:16:24 +01:00
Younes ENNAJI b2a102023b docs: update README.md file 2024-10-27 14:12:39 +01:00
Younes ENNAJI 2a85dc37c3 chore: upgrade dependencies 2024-10-27 12:16:39 +01:00
Younes ENNAJI 46f2397cdc chore: bump flasher dependency to v2.1.1 2024-10-20 15:11:19 +01:00
Younes ENNAJI 57d4665b62 Merge pull request #203 from php-flasher/laravel-excluded-paths
chore: add Laravel excluded paths option
2024-10-20 15:08:15 +01:00
Younes ENNAJI cf3943bc08 fix: phpstan return type 2024-10-20 15:05:07 +01:00
Younes ENNAJI 1da1392670 chore: update CHANGELOG 2024-10-20 15:03:15 +01:00
Younes ENNAJI 095b0d967d chore: add Laravel excluded paths option 2024-10-20 15:01:07 +01:00
Younes ENNAJI 16c1764e73 Merge pull request #202 from php-flasher/symfony-ux
compile assets
2024-10-19 22:13:43 +01:00
Younes ENNAJI 453a0b9c77 chore: compile doc assets 2024-10-19 22:11:20 +01:00
Younes ENNAJI fd051dbf74 chore: compile assets 2024-10-19 22:01:40 +01:00
Younes ENNAJI 2eb8500799 chore: update CHANGELOG 2024-10-19 16:57:02 +01:00
Younes ENNAJI e1b075520b chore: update CHANGELOG 2024-10-19 16:52:53 +01:00
Younes ENNAJI 0477a319b4 chore: update CHANGELOG 2024-10-19 16:52:26 +01:00
Younes ENNAJI 7eaa7a1f46 chore: update CHANGELOG 2024-10-19 16:51:41 +01:00
Younes ENNAJI cdfe882322 chore: run php-cs-fixer 2024-10-19 02:08:58 +01:00
Younes ENNAJI 2ff02a15bf chore: upgrade dependencies 2024-10-19 02:03:11 +01:00
Younes ENNAJI 09f53b1b63 chore: validate and autocomplete flasher configuration 2024-10-19 02:02:53 +01:00
Younes ENNAJI d0022aa0cb docs: comment options array as that's the default value 2024-10-19 00:42:02 +01:00
Younes ENNAJI 632c0662e4 docs: add note about optional configuration values 2024-10-19 00:39:28 +01:00
Younes ENNAJI e8ee494e13 chore: remove whitespaces from docs 2024-10-13 23:54:46 +01:00
Younes ENNAJI fdaa8f8961 Merge pull request #201 from php-flasher/configuration
chore: update laravel and symfony configuration documentation
2024-10-13 23:52:41 +01:00
Younes ENNAJI aa645778e3 chore: update laravel and symfony configuration documentation 2024-10-13 23:51:34 +01:00
Younes ENNAJI aca71922e8 Merge pull request #200 from php-flasher/phpstan
Improve Type Safety and IDE Support with Enhanced PHPDoc Annotations and Stricter PHPStan Validations
2024-10-13 21:42:41 +01:00
Younes ENNAJI 08b96bdd39 chore: enhance type safety with detailed PHPDoc annotations and stricter PHPStan validations 2024-10-13 21:39:22 +01:00
Younes ENNAJI 89d8c2cb7a chore: upgrade dependencies 2024-10-06 16:24:45 +01:00
Younes ENNAJI 004334f642 chore: clean up build files 2024-10-06 15:54:53 +01:00
Younes ENNAJI 60d0f2ed30 remove .npmignore file 2024-10-06 15:23:10 +01:00
Younes ENNAJI d82a12d8c8 update docs description tag 2024-10-06 15:05:14 +01:00
Younes ENNAJI 7b190bf882 update Linkedin profile 2024-10-06 14:44:28 +01:00
Younes ENNAJI 18763f1df0 fix email address in README 2024-10-06 14:43:18 +01:00
Younes ENNAJI 486329be24 Merge pull request #199 from php-flasher/feat/config
[Symfony] Improve configuration descriptions and add examples
2024-10-06 14:33:05 +01:00
Younes ENNAJI c0c8d7d5da chore: improve configuration descriptions and add examples 2024-10-06 14:32:10 +01:00
Younes ENNAJI 8cbf37b29b Merge pull request #198 from php-flasher/feat/profiler
feat(Symfony): Add Symfony Profiler integration for PHPFlasher
2024-10-06 13:37:40 +01:00
Younes ENNAJI 43affdc543 chore: add Symfony Profiler integration for PHPFlasher 2024-10-05 15:34:57 +01:00
Younes ENNAJI b6afde2990 chore: update CHANGELOG 2024-09-22 15:32:58 +01:00
Younes ENNAJI e28123fb3c Merge pull request #197 from php-flasher/issues/190
refactor: FlasherServiceProvider Update HttpKernel import and reorder methods
2024-09-22 15:28:35 +01:00
Younes ENNAJI 79717cae5c refactor: FlasherServiceProvider Update HttpKernel import and reorder methods
- Changed HttpKernel import from Illuminate\Foundation\Http\Kernel to Illuminate\Contracts\Http\Kernel to use the contract interface instead of the concrete implementation.
- Moved registerCspHandler() and registerAssetManager() methods after registerSessionMiddleware() to improve code organization and ensure correct initialization order.
2024-09-22 15:26:49 +01:00
Younes ENNAJI 6fe3407fae chore: upgrade dependencies 2024-09-22 15:21:45 +01:00
Younes ENNAJI 8d0dff2224 Add a friendly call-to-action encouraging users to star the repo and contribute to the docs 2024-09-21 23:42:57 +01:00
Younes ENNAJI 8047c6f6fe chore: update CHANGELOG 2024-09-21 23:30:49 +01:00
Younes ENNAJI c6bdaca89c chore: compile assets 2024-09-21 23:26:23 +01:00
Younes ENNAJI 8e10065c25 style: remove unused border from flasher.scss 2024-09-21 23:25:57 +01:00
Younes ENNAJI cd592be772 docs: update inertial doc page 2024-09-21 23:15:00 +01:00
Younes ENNAJI 1a90c1347e docs: update livewire doc page 2024-09-21 23:12:03 +01:00
Younes ENNAJI 0e3d300390 docs: update laravel doc page 2024-09-21 23:07:48 +01:00
Younes ENNAJI e5507140c8 docs: update symfony doc page 2024-09-21 21:17:27 +01:00
Younes ENNAJI cd43f73b88 docs: update the homepage 2024-09-21 20:46:50 +01:00
Younes ENNAJI 8e026bea78 upgrade dependencies 2024-09-21 20:23:42 +01:00
Younes ENNAJI a5308b85da add palestine banner support to nested repositories 2024-09-21 19:14:36 +01:00
Younes ENNAJI ed522d51a5 chore: update palestine support banner 2024-09-21 19:10:56 +01:00
Younes ENNAJI d9c31820e0 chore: update palestine support banner 2024-09-21 19:03:22 +01:00
Younes ENNAJI eb60a63200 chore: add support palestine banner 2024-09-21 19:00:37 +01:00
Younes ENNAJI 58ca234a37 chore: upgrade dependencies 2024-09-21 18:33:59 +01:00
211 changed files with 22654 additions and 13974 deletions
+10 -1
View File
@@ -1,9 +1,18 @@
--ignore-dir=.idea
--ignore-dir=.cache
--ignore-dir=vendor
--ignore-dir=yoeunes
--ignore-dir=node_modules
--ignore-dir=demo/laravel/vendor
--ignore-dir=demo/laravel/node_modules
--ignore-dir=demo/laravel/storage
--ignore-dir=demo/laravel/bootstrap/cache
--ignore-dir=demo/symfony/vendor
--ignore-dir=.cache
--ignore-dir=demo/symfony/node_modules
--ignore-dir=demo/symfony/var
--ignore-dir=docs/.jekyll-cache
--ignore-dir=docs/_site
--ignore-dir=docs/node_modules
+9
View File
@@ -95,6 +95,15 @@
"code",
"doc"
]
},
{
"login": "BrookeDot",
"name": "Brooke.",
"avatar_url": "https://avatars.githubusercontent.com/u/150348?v=4",
"profile": "https://github.com/BrookeDot",
"contributions": [
"doc"
]
}
]
}
+61
View File
@@ -0,0 +1,61 @@
name: 🚀 Publish assets to NPM
on:
release:
types: [ published ]
jobs:
publish-prime:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./src/Prime/Resources
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install
- name: Publish to NPM
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-plugin:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
matrix:
path:
- ./src/Noty/Prime/Resources
- ./src/Notyf/Prime/Resources
- ./src/SweetAlert/Prime/Resources
- ./src/Toastr/Prime/Resources
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm install
working-directory: ${{ matrix.path }}
- name: Publish to NPM
run: npm publish --access public
working-directory: ${{ matrix.path }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
+14 -17
View File
@@ -1,22 +1,19 @@
.idea/
.DS_Store
/.idea/
/.DS_Store
vendor/
node_modules/
/vendor/
/node_modules/
.cache/php-cs-fixer/
.cache/phpunit/
.cache/phpstan/
.cache/phplint/
.cache/nx/
.nx/
/.cache/php-cs-fixer/
/.cache/phplint/
/.cache/phpstan/
/.cache/phpunit/
.php-cs-fixer.php
phpunit.xml
taskfile.yml
phpstan.neon
/.php-cs-fixer.php
/phpunit.xml
/taskfile.yml
/phpstan.neon
lerna-debug.log
npm-debug.log
/npm-debug.log
tests/Symfony/Fixtures/project/public/vendor/
/tests/Symfony/Fixtures/project/public/vendor/
-8
View File
@@ -1,8 +0,0 @@
*.log
npm-debug.log*
# Coverage directory used by tools like istanbul
coverage
# Dependency directories
node_modules
+1 -1
View File
@@ -1 +1 @@
22.9.0
23.0.0
-3
View File
@@ -1,6 +1,3 @@
pnpm-lock.yaml
pnpm-workspace.yaml
**/node_modules
src/**/Resources/public/**
src/**/Resources/dist/**
+8
View File
@@ -0,0 +1,8 @@
Please do not submit any Pull Requests here. They will be closed.
---
Please submit your PR here instead:
https://github.com/php-flasher/php-flasher
This repository is what we call a "subtree split": a read-only subset of that main repository.
We're looking forward to your PR there!
-23
View File
@@ -1,23 +0,0 @@
name: Auto Closer PR
on:
pull_request_target:
types: [ opened ]
jobs:
run:
name: 🤖 PR Auto-Closure
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: |
Hi there 👋,
First off, thanks for your effort! 🎉 Unfortunately, this repository is read-only because it's split from our primary monorepo repository.
🙏 We kindly ask if you could direct your valuable contribution to our main repository at https://github.com/php-flasher/php-flasher.
Once you've moved your contribution there, we'll review it and provide feedback. 🕵️‍♂️
Thanks again for your understanding and cooperation. We really appreciate it! 🙌
+20
View File
@@ -0,0 +1,20 @@
name: Close Pull Request
on:
pull_request_target:
types: [opened]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: |
Thanks for your Pull Request! We love contributions.
However, you should instead open your PR on the main repository:
https://github.com/php-flasher/php-flasher
This repository is what we call a "subtree split": a read-only subset of that main repository.
We're looking forward to your PR there!
+28 -1
View File
@@ -1,6 +1,33 @@
# CHANGELOG for 2.x
## [Unreleased](https://github.com/php-flasher/php-flasher/compare/v2.0.2...2.x)
## [Unreleased](https://github.com/php-flasher/php-flasher/compare/v2.1.4...2.x)
## [v2.1.3](https://github.com/php-flasher/php-flasher/compare/v2.1.2...v2.1.3) - 2025-01-25
* bug [#208](https://github.com/php-flasher/php-flasher/issues/208) [Flasher] Add GitHub workflow for automatic publishing of assets to NPM. See [PR #211](https://github.com/php-flasher/php-flasher/pull/211) by [ToshY](https://github.com/ToshY)
## [v2.1.2](https://github.com/php-flasher/php-flasher/compare/v2.1.1...v2.1.2) - 2025-01-18
* bug [#208](https://github.com/php-flasher/php-flasher/issues/208) [Flasher] Allow `main_script` to be nullable. See [PR #209](https://github.com/php-flasher/php-flasher/pull/209) by [yoeunes](https://github.com/yoeunes)
## [v2.1.1](https://github.com/php-flasher/php-flasher/compare/v2.1.0...v2.1.1) - 2024-10-20
* feature [Laravel] Add `excluded_paths` option. See [PR #203](https://github.com/php-flasher/php-flasher/pull/203) by [yoeunes](https://github.com/yoeunes)
## [v2.1.0](https://github.com/php-flasher/php-flasher/compare/v2.0.4...v2.1.0) - 2024-10-19
* feature [Flasher] Update laravel and symfony configuration documentation . See [PR #201](https://github.com/php-flasher/php-flasher/pull/201) by [yoeunes](https://github.com/yoeunes)
* feature [Flasher] Improve Type Safety and IDE Support with Enhanced PHPDoc Annotations and Stricter PHPStan Validations. See [PR #200](https://github.com/php-flasher/php-flasher/pull/200) by [yoeunes](https://github.com/yoeunes)
* feature [Symfony] Improve configuration descriptions and add examples. See [PR #199](https://github.com/php-flasher/php-flasher/pull/199) by [yoeunes](https://github.com/yoeunes)
* feature [Symfony] Add Symfony Profiler integration for PHPFlasher. See [PR #198](https://github.com/php-flasher/php-flasher/pull/198) by [yoeunes](https://github.com/yoeunes)
## [v2.0.4](https://github.com/php-flasher/php-flasher/compare/v2.0.3...v2.0.4) - 2024-09-22
* bug [laravel] Changed HttpKernel import from `Illuminate\Foundation\Http\Kernel` to `Illuminate\Contracts\Http\Kernel` to use the contract interface instead of the concrete implementation. See [PR #197](https://github.com/php-flasher/php-flasher/pull/197) by [yoeunes](https://github.com/yoeunes)
## [v2.0.3](https://github.com/php-flasher/php-flasher/compare/v2.0.2...v2.0.3) - 2024-09-21
* remove border from flasher container by [yoeunes](https://github.com/yoeunes)
## [v2.0.2](https://github.com/php-flasher/php-flasher/compare/v2.0.1...v2.0.2) - 2024-09-19
+220 -12
View File
@@ -1,25 +1,232 @@
<div align="center">
<a href="https://github.com/php-flasher/php-flasher/blob/2.x/docs/palestine.md">
<img src="https://raw.githubusercontent.com/php-flasher/art/main/palestine-banner-support.svg" width="800px" alt="Help Palestine"/>
</a>
</div>
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/php-flasher/art/main/php-flasher-github-dark.png">
<img src="https://raw.githubusercontent.com/php-flasher/art/main/php-flasher-github.png" alt="PHPFlasher Logo">
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/php-flasher/art/main/php-flasher-logo-dark.png">
<img src="https://raw.githubusercontent.com/php-flasher/art/main/php-flasher-logo.png" alt="PHPFlasher Logo">
</picture>
</p>
<p align="center">
<a href="https://www.linkedin.com/in/younes--ennaji"><img src="https://img.shields.io/badge/author-@yoeunes-blue.svg" alt="Author Badge"></a>
<a href="https://github.com/php-flasher/php-flasher"><img src="https://img.shields.io/badge/source-php--flasher/php--flasher-blue.svg" alt="Source Code Badge"></a>
<a href="https://github.com/php-flasher/php-flasher/releases"><img src="https://img.shields.io/github/tag/php-flasher/flasher.svg" alt="GitHub Release Badge"></a>
<a href="https://github.com/php-flasher/flasher/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-brightgreen.svg" alt="License Badge"></a>
<a href="https://packagist.org/packages/php-flasher/flasher"><img src="https://img.shields.io/packagist/dt/php-flasher/flasher.svg" alt="Packagist Downloads Badge"></a>
<a href="https://github.com/php-flasher/php-flasher"><img src="https://img.shields.io/github/stars/php-flasher/php-flasher.svg" alt="GitHub Stars Badge"></a>
<a href="https://packagist.org/packages/php-flasher/flasher"><img src="https://img.shields.io/packagist/php-v/php-flasher/flasher.svg" alt="Supported PHP Version Badge"></a>
</p>
## Table of Contents
- [About PHPFlasher](#about-phpflasher)
- [Features](#features)
- [Supported Versions](#supported-versions)
- [Installation](#installation)
- [Core Package](#core-package)
- [Adapters](#adapters)
- [Quick Start](#quick-start)
- [Usage Examples](#usage-examples)
- [Adapters Overview](#adapters-overview)
- [Official Documentation](#official-documentation)
- [Contributors and Sponsors](#contributors-and-sponsors)
- [Contact](#contact)
- [License](#license)
## About PHPFlasher
PHPFlasher is a powerful and easy-to-use package that allows you to quickly and easily add flash messages to your Laravel or Symfony projects.
Whether you need to alert users of a successful form submission, an error, or any other important information, flash messages are a simple and effective solution for providing feedback to your users.
PHPFlasher is an open-source tool that helps you add flash messages to your web applications. Flash messages are short notifications that provide feedback to users after they perform actions, such as submitting a form or encountering an error. These messages enhance the user experience by informing users about the outcomes of their actions.
With PHPFlasher, you can easily record and store messages within the session, making it simple to retrieve and display them on the current or next page.
This improves user engagement and enhances the overall user experience on your website or application.
PHPFlasher simplifies the process of integrating flash messages into **Laravel** and **Symfony** projects. It uses sessions to store messages, allowing you to set a message on one page and display it on another without complex setup.
Whether you're a beginner or an experienced developer, PHPFlasher's intuitive and straightforward design makes it easy to integrate into your projects.
So, if you're looking for a reliable, flexible and easy to use flash messages solution, PHPFlasher is the perfect choice.
## Features
- **Multiple Adapters**: Supports Laravel, Symfony, Toastr, Noty, SweetAlert, and more.
- **Flexible Configuration**: Customize the appearance and behavior of flash messages.
- **Extensible**: Easily integrate with various frontend libraries and frameworks.
- **Intuitive API**: Simple functions to create and manage flash messages.
## Supported Versions
| PHPFlasher Version | PHP Version | Symfony Version | Laravel Version |
|--------------------|-------------|-----------------|-----------------|
| **v2.x** | ≥ 8.2 | ≥ 7.2 | ≥ 11 |
| **v1.x** | ≥ 5.3 | ≥ 2.0 | ≥ 4.0 |
> **Note:** If your project uses PHP, Symfony, or Laravel versions below the requirements for PHPFlasher v2.x, please use [PHPFlasher v1.x](https://github.com/php-flasher/php-flasher/tree/1.x).
## Installation
### Core Package
Install the core PHPFlasher package via Composer:
- **For Laravel:**
```bash
composer require php-flasher/flasher-laravel
```
After installation, set up the necessary assets:
```shell
php artisan flasher:install
```
> **Note:** PHPFlasher automatically injects the necessary JavaScript and CSS assets into your Blade templates. No additional steps are required for asset injection.
- **For Symfony:**
```bash
composer require php-flasher/flasher-symfony
```
After installation, set up the necessary assets:
```shell
php bin/console flasher:install
```
> **Note:** PHPFlasher automatically injects the necessary JavaScript and CSS assets into your Twig templates. No additional steps are required for asset injection.
### Adapters
PHPFlasher provides various adapters for different frameworks and notification libraries. Below is an overview of available adapters:
#### Toastr
- [flasher-toastr](https://github.com/php-flasher/flasher-toastr) - Core Toastr Adapter
- [flasher-toastr-laravel](https://github.com/php-flasher/flasher-toastr-laravel) - Laravel Adapter
- [flasher-toastr-symfony](https://github.com/php-flasher/flasher-toastr-symfony) - Symfony Adapter
#### Noty
- [flasher-noty](https://github.com/php-flasher/flasher-noty) - Core Noty Adapter
- [flasher-noty-laravel](https://github.com/php-flasher/flasher-noty-laravel) - Laravel Adapter
- [flasher-noty-symfony](https://github.com/php-flasher/flasher-noty-symfony) - Symfony Adapter
#### Notyf
- [flasher-notyf](https://github.com/php-flasher/flasher-notyf) - Core Notyf Adapter
- [flasher-notyf-laravel](https://github.com/php-flasher/flasher-notyf-laravel) - Laravel Adapter
- [flasher-notyf-symfony](https://github.com/php-flasher/flasher-notyf-symfony) - Symfony Adapter
#### SweetAlert
- [flasher-sweetalert](https://github.com/php-flasher/flasher-sweetalert) - Core SweetAlert Adapter
- [flasher-sweetalert-laravel](https://github.com/php-flasher/flasher-sweetalert-laravel) - Laravel Adapter
- [flasher-sweetalert-symfony](https://github.com/php-flasher/flasher-sweetalert-symfony) - Symfony Adapter
For detailed installation and usage instructions for each adapter, refer to their respective [README.md](https://github.com/php-flasher/flasher-toastr).
## Quick Start
To display a notification message, you can either use the `flash()` helper function or obtain an instance of `flasher` from the service container. Then, before returning a view or redirecting, call the desired method (`success()`, `error()`, etc.) and pass in the message to be displayed.
### Using the `flash()` Helper
```php
class BookController
{
public function saveBook()
{
// Your logic here
flash('Your changes have been saved!');
return redirect()->back();
}
}
```
### Using the `flasher` Service
```php
use Flasher\Prime\FlasherInterface;
class AnotherController
{
/**
* If you prefer to use dependency injection
*/
public function register(FlasherInterface $flasher)
{
// Your logic here
$flasher->success('Your changes have been saved!');
// ... redirect or render the view
}
public function update()
{
// Your logic here
app('flasher')->error('An error occurred while updating.'); // ony for laravel
return redirect()->back();
}
}
```
## Usage Examples
### Success Message
```php
flash()->success('Operation completed successfully!');
```
### Error Message
```php
flash()->error('An error occurred.');
```
### Info Message
```php
flash()->info('This is an informational message.');
```
### Warning Message
```php
flash()->warning('This is a warning message.');
```
### Passing Options
```php
flash()->success('Custom message with options.', ['timeout' => 3000, 'position' => 'bottom-left']);
```
## Adapters Overview
PHPFlasher supports various adapters to integrate seamlessly with different frameworks and frontend libraries. Below is an overview of available adapters:
| Adapter Repository | Description |
|-----------------------------------------------------------------------------------------|--------------------------------|
| [flasher-laravel](https://github.com/php-flasher/flasher-laravel) | Laravel framework adapter |
| [flasher-symfony](https://github.com/php-flasher/flasher-symfony) | Symfony framework adapter |
| [flasher-toastr-laravel](https://github.com/php-flasher/flasher-toastr-laravel) | Toastr adapter for Laravel |
| [flasher-toastr-symfony](https://github.com/php-flasher/flasher-toastr-symfony) | Toastr adapter for Symfony |
| [flasher-noty-laravel](https://github.com/php-flasher/flasher-noty-laravel) | Noty adapter for Laravel |
| [flasher-noty-symfony](https://github.com/php-flasher/flasher-noty-symfony) | Noty adapter for Symfony |
| [flasher-notyf-laravel](https://github.com/php-flasher/flasher-notyf-laravel) | Notyf adapter for Laravel |
| [flasher-notyf-symfony](https://github.com/php-flasher/flasher-notyf-symfony) | Notyf adapter for Symfony |
| [flasher-sweetalert-laravel](https://github.com/php-flasher/flasher-sweetalert-laravel) | SweetAlert adapter for Laravel |
| [flasher-sweetalert-symfony](https://github.com/php-flasher/flasher-sweetalert-symfony) | SweetAlert adapter for Symfony |
> **Note:** Each adapter has its own repository. For detailed installation and usage instructions, please refer to the [Official Documentation](https://php-flasher.io).
## Official Documentation
Documentation for PHPFlasher can be found on the [https://php-flasher.io](https://php-flasher.io).
Comprehensive documentation for PHPFlasher is available at [https://php-flasher.io](https://php-flasher.io). Here you will find detailed guides, API references, and advanced usage examples to help you get the most out of PHPFlasher.
## Contributors and sponsors
@@ -47,6 +254,7 @@ Shining stars of our community:
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://www.instagram.com/lucas.maciel_z"><img src="https://avatars.githubusercontent.com/u/80225404?v=4?s=100" width="100px;" alt="Lucas Maciel"/><br /><sub><b>Lucas Maciel</b></sub></a><br /><a href="#design-LucasStorm" title="Design">🎨</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/AhmedGamal"><img src="https://avatars.githubusercontent.com/u/11786167?v=4?s=100" width="100px;" alt="Ahmed Gamal"/><br /><sub><b>Ahmed Gamal</b></sub></a><br /><a href="https://github.com/php-flasher/php-flasher/commits?author=AhmedGamal" title="Code">💻</a> <a href="https://github.com/php-flasher/php-flasher/commits?author=AhmedGamal" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/BrookeDot"><img src="https://avatars.githubusercontent.com/u/150348?v=4?s=100" width="100px;" alt="Brooke."/><br /><sub><b>Brooke.</b></sub></a><br /><a href="https://github.com/php-flasher/php-flasher/commits?author=BrookeDot" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
@@ -64,11 +272,11 @@ You can reach out with questions, bug reports, or feature requests on any of the
- [Github Issues](https://github.com/php-flasher/php-flasher/issues)
- [Github](https://github.com/yoeunes)
- [Twitter](https://twitter.com/yoeunes)
- [Linkedin](https://www.linkedin.com/in/younes-ennaji/)
- [Email me directly](mailto:younes.ennaji@gmail.com)
- [Linkedin](https://www.linkedin.com/in/younes--ennaji/)
- [Email me directly](mailto:younes.ennaji.pro@gmail.com)
## License
PHPFlasher is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
<p align="center"> <b>Made with ❤️ by <a href="https://www.linkedin.com/in/younes-ennaji/">Younes ENNAJI</a> </b> </p>
<p align="center"> <b>Made with ❤️ by <a href="https://www.linkedin.com/in/younes--ennaji/">Younes ENNAJI</a> </b> </p>
+48 -28
View File
@@ -1,50 +1,70 @@
#!/usr/bin/env php
<?php
declare(strict_types=1);
require __DIR__.'/../vendor/autoload.php';
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
$filesystem = new Filesystem();
// Define the shared resources
$shared = realpath(__DIR__.'/../.shared');
$resources = array(
$resources = [
$shared,
__DIR__.'/../.github/FUNDING.yml',
__DIR__.'/../README.md',
__DIR__.'/../LICENSE',
);
];
$dirs = array(__DIR__.'/../packs', __DIR__.'/../src');
// Directories to search for packages
$dirs = [__DIR__.'/../src'];
$packages = array_reduce($dirs, function ($files, $dir) {
return array_merge($files, glob("$dir/*/composer.json"), glob("$dir/*/*/composer.json"));
}, array());
// Find all composer.json files within the specified directories
$finder = new Finder();
$finder->files()
->in($dirs)
->name('composer.json')
->depth('< 3'); // Adjust depth as needed
foreach ($packages as $package) {
$package = realpath(dirname($package));
$packages = [];
// Collect package directories
foreach ($finder as $file) {
$packages[] = dirname($file->getRealPath());
}
foreach ($packages as $packageDir) {
foreach ($resources as $resource) {
$resource = realpath($resource);
$dest = $package.str_replace(realpath(__DIR__.'/../'), '', $resource);
if (!is_dir($resource) && file_exists($resource)) {
copy($resource, $dest);
if (!is_string($resource)) {
continue;
}
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($resource, FilesystemIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST
);
$resourcePath = realpath($resource);
foreach ($files as $file) {
$target = $resource === $shared
? $package.str_replace($resource, '', $file->getPathname())
: $dest .'/'. $file->getFilename();
if (!$resourcePath) {
continue; // Skip if the resource doesn't exist
}
if ($file->isDir()) {
system('rm -rf -- ' . escapeshellarg($dest));
@mkdir(dirname($target), 0777, true);
continue;
$relativePath = str_replace(realpath(__DIR__.'/../') ?: '', '', $resourcePath);
$destination = $packageDir.$relativePath;
if (is_file($resourcePath)) {
// Ensure the destination directory exists
$filesystem->mkdir(dirname($destination));
// Copy the file
$filesystem->copy($resourcePath, $destination, true);
} elseif (is_dir($resourcePath)) {
if ($resourcePath === $shared) {
// Copy contents of the shared directory into the package directory
$filesystem->mirror($shared, $packageDir, null, ['override' => true]);
} else {
// Copy the entire directory to the destination
$filesystem->mirror($resourcePath, $destination, null, ['override' => true]);
}
@mkdir(dirname($target), 0777, true);
@copy($file->getPathname(), $target);
}
}
}
Executable
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -e
NPM_FOLDERS=(
"src/Prime/Resources"
"src/Noty/Prime/Resources"
"src/Notyf/Prime/Resources"
"src/SweetAlert/Prime/Resources"
"src/Toastr/Prime/Resources"
)
for folder in "${NPM_FOLDERS[@]}"; do
if [ -d "$folder" ]; then
echo ""
echo "Publishing $folder to npm..."
(
cd "$folder"
npm install
npm version "$VERSION" --no-git-tag-version || true
npm publish --access public
)
fi
done
echo "Release $VERSION complete tagged repositories and published packages to npm."
+23 -21
View File
@@ -21,27 +21,14 @@
"prefer-stable": true,
"require": {
"php": ">=8.2",
"ext-intl": "*"
},
"require-dev": {
"illuminate/routing": "^11.0",
"illuminate/support": "^11.0",
"larastan/larastan": "^2.9",
"ext-intl": "*",
"illuminate/contracts": "^11.0|^12.0",
"illuminate/routing": "^11.0|^12.0",
"illuminate/support": "^11.0|^12.0",
"laravel/octane": "^2.3",
"livewire/livewire": "^3.5",
"mockery/mockery": "^1.6",
"orchestra/testbench": "^9.4",
"overtrue/phplint": "^9.4",
"php-cs-fixer/shim": "^3.64",
"phpstan/phpstan": "^1.12",
"phpstan/phpstan-mockery": "^1.1",
"phpstan/phpstan-phpunit": "^1.4",
"phpstan/phpstan-symfony": "^1.4",
"phpunit/phpunit": "^10.5",
"livewire/livewire": "^3.0",
"paragonie/random_compat": "^2.0",
"psr/container": "^1.1|^2.0",
"rector/rector": "^1.2",
"rector/swiss-knife": "^0.2",
"spatie/ray": "^1.41",
"symfony/config": "^7.0",
"symfony/console": "^7.0",
"symfony/dependency-injection": "^7.0",
@@ -49,8 +36,23 @@
"symfony/http-kernel": "^7.0",
"symfony/translation": "^7.0",
"symfony/twig-bundle": "^7.0",
"symfony/ux-twig-component": "^2.19",
"symplify/monorepo-builder": "^11.2"
"symfony/ux-twig-component": "^2.19"
},
"require-dev": {
"larastan/larastan": "^2.9.9",
"mockery/mockery": "^1.6.12",
"orchestra/testbench": "^9.5.2",
"overtrue/phplint": "^9.5.3",
"php-cs-fixer/shim": "^3.64.0",
"phpstan/phpstan": "^1.12.7",
"phpstan/phpstan-mockery": "^1.1.3",
"phpstan/phpstan-phpunit": "^1.4.0",
"phpstan/phpstan-symfony": "^1.4.10",
"phpunit/phpunit": "^10.5.26",
"rector/rector": "^1.2.8",
"rector/swiss-knife": "^1.0.0",
"spatie/ray": "^1.41.2",
"symplify/monorepo-builder": "^11.2.22"
},
"autoload": {
"psr-4": {
Generated
+5383 -5372
View File
File diff suppressed because it is too large Load Diff
+64
View File
@@ -0,0 +1,64 @@
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:mNtM4UEOfGE4dx7IAH4+kx4iPYPdGeu+Gaw/PIcF4II=
APP_DEBUG=true
APP_TIMEZONE=UTC
APP_URL=http://localhost
APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US
APP_MAINTENANCE_DRIVER=file
APP_MAINTENANCE_STORE=database
BCRYPT_ROUNDS=12
LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null
BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database
CACHE_STORE=database
CACHE_PREFIX=
MEMCACHED_HOST=127.0.0.1
REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
MAIL_MAILER=log
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
VITE_APP_NAME="${APP_NAME}"
+1 -1
View File
@@ -2,10 +2,10 @@
/node_modules
/public/build
/public/hot
/public/vendor/flasher
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.env.production
.phpunit.result.cache
+5 -1
View File
@@ -3,16 +3,20 @@
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
use Illuminate\Support\Facades\Route;
return Application::configure(basePath: dirname(__DIR__))
->withRouting(
web: __DIR__.'/../routes/web.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
then: function () {
Route::middleware('web')->group(base_path('routes/issues.php'));
},
)
->withMiddleware(function (Middleware $middleware) {
$middleware->web(append: [
\App\Http\Middleware\HandleInertiaRequests::class,
App\Http\Middleware\HandleInertiaRequests::class,
]);
})
->withExceptions(function (Exceptions $exceptions) {
+23 -18
View File
@@ -15,24 +15,26 @@
],
"require": {
"php": "^8.2",
"inertiajs/inertia-laravel": "^1.0",
"laravel/framework": "^11.0",
"laravel/tinker": "^2.9",
"livewire/livewire": "^3.4",
"inertiajs/inertia-laravel": "^2.0.1",
"laravel/framework": "^11.43.2",
"laravel/tinker": "^2.10.1",
"livewire/livewire": "^3.5.20",
"php-flasher/php-flasher": "@dev",
"spatie/laravel-csp": "^2.9",
"spatie/laravel-ray": "^1.36"
"spatie/laravel-csp": "^2.10.3",
"spatie/laravel-ray": "^1.39.1"
},
"require-dev": {
"fakerphp/faker": "^1.23",
"larastan/larastan": "^2.9",
"laravel/pint": "^1.13",
"laravel/sail": "^1.26",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.0",
"pestphp/pest": "^2.34",
"pestphp/pest-plugin-laravel": "^2.3",
"spatie/laravel-ignition": "^2.4"
"barryvdh/laravel-debugbar": "^3.15",
"fakerphp/faker": "^1.24.1",
"larastan/larastan": "^3.1",
"laravel/pint": "^1.21",
"laravel/sail": "^1.41",
"mockery/mockery": "^1.6.12",
"nunomaduro/collision": "^8.6.1",
"pestphp/pest": "^3.7.4",
"pestphp/pest-plugin-laravel": "^3.1",
"spatie/laravel-ignition": "^2.9.1",
"spatie/ray": "^1.41.5"
},
"autoload": {
"psr-4": {
@@ -49,13 +51,16 @@
"scripts": {
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover --ansi"
"@php artisan package:discover --ansi",
"@php artisan flasher:install --symlink"
],
"post-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
"@php artisan vendor:publish --tag=laravel-assets --ansi --force",
"@php artisan flasher:install --symlink"
],
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"",
"@php artisan flasher:install --symlink"
],
"post-create-project-cmd": [
"@php artisan key:generate --ansi",
+3520 -1459
View File
File diff suppressed because it is too large Load Diff
+15
View File
@@ -0,0 +1,15 @@
<?php
declare(strict_types=1);
use Illuminate\Support\Facades\Route;
Route::get('/issues/190', function () {
flash()->success('Your order has been placed successfully.');
// Passing another success message with the view
return redirect('/issues/190/redirect')->with('success', 'Your order will be delivered in 3-5 business days.');
});
Route::get('/issues/190/redirect', function () {
return view('welcome');
});
+16 -12
View File
@@ -1,23 +1,27 @@
<?php
declare(strict_types=1);
use App\Entity\Book;
use Illuminate\Support\Facades\Route;
Route::get('/', function () {
// sweetalert()->timerProgressBar()->success('hello from Home Controller');
// noty()->layout('topCenter')->success('hello from Home Controller');
// notyf()->ripple(false)->warning('hello from Home Controller');
// toastr()->positionClass('toast-bottom-left')->error('hello from Home Controller');
// flash()->use('flasher')->success('hello from flasher factory');
// flash()->created(new Book('lord of the rings'));
// flash()->saved(new Book('harry potter'));
session()->flash('success', 'this from laravel session flash');
return redirect('/redirect');
sweetalert()->timerProgressBar()->success('Your account has been successfully created!');
noty()->layout('topCenter')->success('Welcome back, John Doe!');
notyf()->ripple(false)->warning('Your subscription is about to expire in 3 days.');
toastr()->positionClass('toast-bottom-left')->error('Payment failed. Please try again.');
flash()->use('flasher')->success('Your profile has been updated successfully.');
flash()->created(new Book('The Great Gatsby'));
flash()->saved(new Book('1984'));
session()->flash('success', 'Your settings have been saved.');
return view('welcome');
})->name('app_home');
Route::get('/redirect', function () {
session()->flash('success', 'You have been redirected successfully.');
return redirect('/destination');
});
Route::get('/destination', function () {
return view('welcome');
});
+2
View File
@@ -0,0 +1,2 @@
*
!.gitignore
+4
View File
@@ -0,0 +1,4 @@
--ignore-dir=vendor
--ignore-dir=yoeunes
--ignore-dir=node_modules
--ignore-dir=var
+4
View File
@@ -18,3 +18,7 @@
APP_ENV=dev
APP_SECRET=a2ee898b9e385a80ba8f7b11e97232b2
###< symfony/framework-bundle ###
###> symfony/mailer ###
MAILER_DSN=null://null
###< symfony/mailer ###
+1
View File
@@ -5,6 +5,7 @@
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/public/vendor/flasherg
/var/
/vendor/
###< symfony/framework-bundle ###
+1
View File
@@ -0,0 +1 @@
8.2
+1
View File
@@ -0,0 +1 @@
php=php@8.2
+24 -17
View File
@@ -16,19 +16,27 @@
"php": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"nelmio/security-bundle": "^3.3",
"nelmio/security-bundle": "^3.4.2",
"php-flasher/php-flasher": "@dev",
"phpstan/phpstan-symfony": "^1.3",
"symfony/console": "7.0.*",
"symfony/dotenv": "7.0.*",
"symfony/flex": "^2",
"symfony/framework-bundle": "7.0.*",
"symfony/runtime": "7.0.*",
"symfony/translation": "7.0.*",
"symfony/twig-bundle": "7.0.*",
"symfony/yaml": "7.0.*",
"twig/extra-bundle": "^2.12|^3.0",
"twig/twig": "^2.12|^3.0"
"phpstan/phpstan-symfony": "^2.0.2",
"symfony/console": "7.2.*",
"symfony/dotenv": "7.2.*",
"symfony/flex": "^2.4.7",
"symfony/framework-bundle": "7.2.*",
"symfony/monolog-bundle": "^3.10",
"symfony/notifier": "7.2.*",
"symfony/runtime": "7.2.*",
"symfony/translation": "7.2.*",
"symfony/twig-bundle": "7.2.*",
"symfony/yaml": "7.2.*",
"twig/extra-bundle": "^2.12|^3.20",
"twig/twig": "^2.12|^3.20"
},
"require-dev": {
"spatie/ray": "^1.41.5",
"symfony/maker-bundle": "^1.62.1",
"symfony/stopwatch": "7.2.*",
"symfony/web-profiler-bundle": "7.2.*"
},
"config": {
"allow-plugins": {
@@ -61,7 +69,8 @@
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
"assets:install %PUBLIC_DIR%": "symfony-cmd",
"flasher:install": "symfony-cmd"
},
"post-install-cmd": [
"@auto-scripts"
@@ -76,10 +85,8 @@
"extra": {
"symfony": {
"allow-contrib": false,
"require": "7.0.*"
"require": "7.2.*",
"docker": false
}
},
"require-dev": {
"symfony/maker-bundle": "^1.58"
}
}
+5273 -460
View File
File diff suppressed because it is too large Load Diff
+3
View File
@@ -11,4 +11,7 @@ return [
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
Nelmio\SecurityBundle\NelmioSecurityBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
Symfony\UX\TwigComponent\TwigComponentBundle::class => ['all' => true],
];
+1 -1
View File
@@ -32,4 +32,4 @@ flasher:
# Criteria to filter displayed notifications (limit, types)
filter:
# Limit number of displayed notifications
limit: 5
# limit: 5
+3
View File
@@ -0,0 +1,3 @@
framework:
mailer:
dsn: '%env(MAILER_DSN)%'
+62
View File
@@ -0,0 +1,62 @@
monolog:
channels:
- deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists
when@dev:
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: ["!event"]
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine", "!console"]
when@test:
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_http_codes: [404, 405]
channels: ["!event"]
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
when@prod:
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
excluded_http_codes: [404, 405]
buffer_size: 50 # How many messages should be saved? Prevent memory leaks
nested:
type: stream
path: php://stderr
level: debug
formatter: monolog.formatter.json
console:
type: console
process_psr_3_messages: false
channels: ["!event", "!doctrine"]
deprecation:
type: stream
channels: [deprecation]
path: php://stderr
formatter: monolog.formatter.json
@@ -0,0 +1,12 @@
framework:
notifier:
chatter_transports:
texter_transports:
channel_policy:
# use chat/slack, chat/telegram, sms/twilio or sms/nexmo
urgent: ['email']
high: ['email']
medium: ['email']
low: ['email']
admin_recipients:
- { email: admin@example.com }
@@ -0,0 +1,5 @@
twig_component:
anonymous_template_directory: 'components/'
defaults:
# Namespace & directory for components
App\Twig\Components\: 'components/'
@@ -0,0 +1,17 @@
when@dev:
web_profiler:
toolbar: true
intercept_redirects: false
framework:
profiler:
only_exceptions: false
collect_serializer_data: true
when@test:
web_profiler:
toolbar: false
intercept_redirects: false
framework:
profiler: { collect: false }
@@ -0,0 +1,8 @@
when@dev:
web_profiler_wdt:
resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
prefix: /_wdt
web_profiler_profiler:
resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
prefix: /_profiler
@@ -0,0 +1 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@flasher/flasher"),require("noty")):"function"==typeof define&&define.amd?define(["@flasher/flasher","noty"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).Noty=t(e.flasher,e.Noty)}(this,(function(e,t){"use strict";class s{success(e,t,s){this.flash("success",e,t,s)}error(e,t,s){this.flash("error",e,t,s)}info(e,t,s){this.flash("info",e,t,s)}warning(e,t,s){this.flash("warning",e,t,s)}flash(e,t,s,o){if("object"==typeof e?(e=(o=e).type,t=o.message,s=o.title):"object"==typeof t?(t=(o=t).message,s=o.title):"object"==typeof s&&(s=(o=s).title),void 0===t)throw new Error("message option is required");const n={type:e,message:t,title:s||e,options:o||{},metadata:{plugin:""}};this.renderOptions(o||{}),this.renderEnvelopes([n])}}const o=new class extends s{renderEnvelopes(e){e.forEach((e=>{var s;const o=Object.assign({text:e.message,type:e.type},e.options),n=new t(o);n.show(),null===(s=n.layoutDom)||void 0===s||(s.dataset.turboTemporary="")}))}renderOptions(e){t.overrideDefaults(Object.assign({timeout:e.timeout||5e3},e))}};return e.addPlugin("noty",o),o}));
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@flasher/flasher"),require("sweetalert2")):"function"==typeof define&&define.amd?define(["@flasher/flasher","sweetalert2"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).sweetalert=t(e.flasher,e.Swal)}(this,(function(e,t){"use strict";function s(e,t,s,n){return new(s||(s=Promise))((function(i,r){function o(e){try{a(n.next(e))}catch(e){r(e)}}function l(e){try{a(n.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,l)}a((n=n.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class n{success(e,t,s){this.flash("success",e,t,s)}error(e,t,s){this.flash("error",e,t,s)}info(e,t,s){this.flash("info",e,t,s)}warning(e,t,s){this.flash("warning",e,t,s)}flash(e,t,s,n){if("object"==typeof e?(e=(n=e).type,t=n.message,s=n.title):"object"==typeof t?(t=(n=t).message,s=n.title):"object"==typeof s&&(s=(n=s).title),void 0===t)throw new Error("message option is required");const i={type:e,message:t,title:s||e,options:n||{},metadata:{plugin:""}};this.renderOptions(n||{}),this.renderEnvelopes([i])}}const i=new class extends n{renderEnvelopes(e){return s(this,void 0,void 0,(function*(){for(const t of e)yield this.renderEnvelope(t)}))}renderOptions(e){this.sweetalert=this.sweetalert||t.mixin(Object.assign({timer:e.timer||5e3,timerProgressBar:e.timerProgressBar||!0},e)),document.addEventListener("turbo:before-cache",(()=>{var e;t.isVisible()&&(null===(e=t.getPopup())||void 0===e||e.style.setProperty("animation-duration","0ms"),t.close())}))}renderEnvelope(e){return s(this,void 0,void 0,(function*(){var t;let{options:s}=e;s=Object.assign(Object.assign({},s),{icon:(null==s?void 0:s.icon)||e.type,text:(null==s?void 0:s.text)||e.message}),yield null===(t=this.sweetalert)||void 0===t?void 0:t.fire(s).then((t=>{window.dispatchEvent(new CustomEvent("flasher:sweetalert:promise",{detail:{promise:t,envelope:e}}))}))}))}};return e.addPlugin("sweetalert",i),i}));
@@ -0,0 +1 @@
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@flasher/flasher"),require("toastr")):"function"==typeof define&&define.amd?define(["@flasher/flasher","toastr"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).toastr=t(e.flasher,e.toastr)}(this,(function(e,t){"use strict";class s{success(e,t,s){this.flash("success",e,t,s)}error(e,t,s){this.flash("error",e,t,s)}info(e,t,s){this.flash("info",e,t,s)}warning(e,t,s){this.flash("warning",e,t,s)}flash(e,t,s,r){if("object"==typeof e?(e=(r=e).type,t=r.message,s=r.title):"object"==typeof t?(t=(r=t).message,s=r.title):"object"==typeof s&&(s=(r=s).title),void 0===t)throw new Error("message option is required");const o={type:e,message:t,title:s||e,options:r||{},metadata:{plugin:""}};this.renderOptions(r||{}),this.renderEnvelopes([o])}}const r=new class extends s{renderEnvelopes(e){e.forEach((e=>{const{message:s,title:r,type:o,options:i}=e,n=t[o](s,r,i);n&&n.parent().attr("data-turbo-temporary","")}))}renderOptions(e){t.options=Object.assign({timeOut:e.timeOut||5e3,progressBar:e.progressBar||!0},e)}};return e.addPlugin("toastr",r),r}));
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+17
View File
@@ -0,0 +1,17 @@
{
"/vendor/flasher/flasher.min.js": "/vendor/flasher/flasher.min.js?id=9a255a6680873c0d5fc3d394a2ba3195",
"/vendor/flasher/flasher.min.css": "/vendor/flasher/flasher.min.css?id=7a96e40c68626198d5128ad2fb5d77e0",
"/vendor/flasher/mint.css": "/vendor/flasher/mint.css?id=348f135fff639305dde0005c647c1d20",
"/vendor/flasher/flasher-noty.min.js": "/vendor/flasher/flasher-noty.min.js?id=d7d160fe2043e65250dfcaa5590d2e28",
"/vendor/flasher/noty.css": "/vendor/flasher/noty.css?id=bf51111a785e04cc8c86a7786e855484",
"/vendor/flasher/noty.min.js": "/vendor/flasher/noty.min.js?id=840a31ddb720ff391cfc386c009d3422",
"/vendor/flasher/flasher-notyf.min.js": "/vendor/flasher/flasher-notyf.min.js?id=d8778adb84f0e2521d413c9ca995309c",
"/vendor/flasher/flasher-notyf.min.css": "/vendor/flasher/flasher-notyf.min.css?id=53f57ecf59a7045f8029243bde3ed054",
"/vendor/flasher/toastr.min.css": "/vendor/flasher/toastr.min.css?id=f284028c678041d687c6f1be6968f68a",
"/vendor/flasher/flasher-toastr.min.js": "/vendor/flasher/flasher-toastr.min.js?id=e0d38991a82d544068555ff7c2a2339b",
"/vendor/flasher/toastr.min.js": "/vendor/flasher/toastr.min.js?id=8ee1218b09fb02d43fcf0b84e30637ad",
"/vendor/flasher/jquery.min.js": "/vendor/flasher/jquery.min.js?id=2c872dbe60f4ba70fb85356113d8b35e",
"/vendor/flasher/sweetalert2.min.js": "/vendor/flasher/sweetalert2.min.js?id=52e4f161dbe2cf71c99dfef9f94fb1ff",
"/vendor/flasher/sweetalert2.min.css": "/vendor/flasher/sweetalert2.min.css?id=a45abfe01a51ef4b1a068fb739f4e540",
"/vendor/flasher/flasher-sweetalert.min.js": "/vendor/flasher/flasher-sweetalert.min.js?id=4ede7e66493a3432961bb00ce83dd4da"
}
+37
View File
@@ -0,0 +1,37 @@
.noty_theme__mint.noty_bar {
margin: 4px 0;
overflow: hidden;
border-radius: 2px;
position: relative; }
.noty_theme__mint.noty_bar .noty_body {
padding: 10px;
font-size: 14px; }
.noty_theme__mint.noty_bar .noty_buttons {
padding: 10px; }
.noty_theme__mint.noty_type__alert,
.noty_theme__mint.noty_type__notification {
background-color: #fff;
border-bottom: 1px solid #D1D1D1;
color: #2F2F2F; }
.noty_theme__mint.noty_type__warning {
background-color: #FFAE42;
border-bottom: 1px solid #E89F3C;
color: #fff; }
.noty_theme__mint.noty_type__error {
background-color: #DE636F;
border-bottom: 1px solid #CA5A65;
color: #fff; }
.noty_theme__mint.noty_type__info,
.noty_theme__mint.noty_type__information {
background-color: #7F7EFF;
border-bottom: 1px solid #7473E8;
color: #fff; }
.noty_theme__mint.noty_type__success {
background-color: #AFC765;
border-bottom: 1px solid #A0B55C;
color: #fff; }
+216
View File
@@ -0,0 +1,216 @@
.noty_layout_mixin, #noty_layout__top, #noty_layout__topLeft, #noty_layout__topCenter, #noty_layout__topRight, #noty_layout__bottom, #noty_layout__bottomLeft, #noty_layout__bottomCenter, #noty_layout__bottomRight, #noty_layout__center, #noty_layout__centerLeft, #noty_layout__centerRight {
position: fixed;
margin: 0;
padding: 0;
z-index: 9999999;
-webkit-transform: translateZ(0) scale(1, 1);
transform: translateZ(0) scale(1, 1);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-font-smoothing: subpixel-antialiased;
filter: blur(0);
-webkit-filter: blur(0);
max-width: 90%; }
#noty_layout__top {
top: 0;
left: 5%;
width: 90%; }
#noty_layout__topLeft {
top: 20px;
left: 20px;
width: 325px; }
#noty_layout__topCenter {
top: 5%;
left: 50%;
width: 325px;
-webkit-transform: translate(-webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1);
transform: translate(calc(-50% - .5px)) translateZ(0) scale(1, 1); }
#noty_layout__topRight {
top: 20px;
right: 20px;
width: 325px; }
#noty_layout__bottom {
bottom: 0;
left: 5%;
width: 90%; }
#noty_layout__bottomLeft {
bottom: 20px;
left: 20px;
width: 325px; }
#noty_layout__bottomCenter {
bottom: 5%;
left: 50%;
width: 325px;
-webkit-transform: translate(-webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1);
transform: translate(calc(-50% - .5px)) translateZ(0) scale(1, 1); }
#noty_layout__bottomRight {
bottom: 20px;
right: 20px;
width: 325px; }
#noty_layout__center {
top: 50%;
left: 50%;
width: 325px;
-webkit-transform: translate(-webkit-calc(-50% - .5px), -webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1);
transform: translate(calc(-50% - .5px), calc(-50% - .5px)) translateZ(0) scale(1, 1); }
#noty_layout__centerLeft {
top: 50%;
left: 20px;
width: 325px;
-webkit-transform: translate(0, -webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1);
transform: translate(0, calc(-50% - .5px)) translateZ(0) scale(1, 1); }
#noty_layout__centerRight {
top: 50%;
right: 20px;
width: 325px;
-webkit-transform: translate(0, -webkit-calc(-50% - .5px)) translateZ(0) scale(1, 1);
transform: translate(0, calc(-50% - .5px)) translateZ(0) scale(1, 1); }
.noty_progressbar {
display: none; }
.noty_has_timeout.noty_has_progressbar .noty_progressbar {
display: block;
position: absolute;
left: 0;
bottom: 0;
height: 3px;
width: 100%;
background-color: #646464;
opacity: 0.2;
filter: alpha(opacity=10); }
.noty_bar {
-webkit-backface-visibility: hidden;
-webkit-transform: translate(0, 0) translateZ(0) scale(1, 1);
-ms-transform: translate(0, 0) scale(1, 1);
transform: translate(0, 0) scale(1, 1);
-webkit-font-smoothing: subpixel-antialiased;
overflow: hidden; }
.noty_effects_open {
opacity: 0;
-webkit-transform: translate(50%);
-ms-transform: translate(50%);
transform: translate(50%);
-webkit-animation: noty_anim_in 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
animation: noty_anim_in 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards; }
.noty_effects_close {
-webkit-animation: noty_anim_out 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
animation: noty_anim_out 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards; }
.noty_fix_effects_height {
-webkit-animation: noty_anim_height 75ms ease-out;
animation: noty_anim_height 75ms ease-out; }
.noty_close_with_click {
cursor: pointer; }
.noty_close_button {
position: absolute;
top: 2px;
right: 2px;
font-weight: bold;
width: 20px;
height: 20px;
text-align: center;
line-height: 20px;
background-color: rgba(0, 0, 0, 0.05);
border-radius: 2px;
cursor: pointer;
-webkit-transition: all .2s ease-out;
transition: all .2s ease-out; }
.noty_close_button:hover {
background-color: rgba(0, 0, 0, 0.1); }
.noty_modal {
position: fixed;
width: 100%;
height: 100%;
background-color: #000;
z-index: 10000;
opacity: .3;
left: 0;
top: 0; }
.noty_modal.noty_modal_open {
opacity: 0;
-webkit-animation: noty_modal_in .3s ease-out;
animation: noty_modal_in .3s ease-out; }
.noty_modal.noty_modal_close {
-webkit-animation: noty_modal_out .3s ease-out;
animation: noty_modal_out .3s ease-out;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards; }
@-webkit-keyframes noty_modal_in {
100% {
opacity: .3; } }
@keyframes noty_modal_in {
100% {
opacity: .3; } }
@-webkit-keyframes noty_modal_out {
100% {
opacity: 0; } }
@keyframes noty_modal_out {
100% {
opacity: 0; } }
@keyframes noty_modal_out {
100% {
opacity: 0; } }
@-webkit-keyframes noty_anim_in {
100% {
-webkit-transform: translate(0);
transform: translate(0);
opacity: 1; } }
@keyframes noty_anim_in {
100% {
-webkit-transform: translate(0);
transform: translate(0);
opacity: 1; } }
@-webkit-keyframes noty_anim_out {
100% {
-webkit-transform: translate(50%);
transform: translate(50%);
opacity: 0; } }
@keyframes noty_anim_out {
100% {
-webkit-transform: translate(50%);
transform: translate(50%);
opacity: 0; } }
@-webkit-keyframes noty_anim_height {
100% {
height: 0; } }
@keyframes noty_anim_height {
100% {
height: 0; } }
/*# sourceMappingURL=noty.css.map*/
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -21,11 +21,9 @@ class HomeController extends AbstractController
flash()->created(new Book('lord of the rings'));
flash()->saved(new Book('harry potter'));
// flash()->updated();
// flash()->deleted();
flash()->updated();
flash()->deleted();
return $this->render('home/index.html.twig', [
'controller_name' => 'HomeController',
]);
return $this->render('home/index.html.twig');
}
}
+70
View File
@@ -66,6 +66,18 @@
"src/Kernel.php"
]
},
"symfony/mailer": {
"version": "7.2",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "4.3",
"ref": "09051cfde49476e3c12cd3a0e44289ace1c75a4f"
},
"files": [
"config/packages/mailer.yaml"
]
},
"symfony/maker-bundle": {
"version": "1.58",
"recipe": {
@@ -75,6 +87,30 @@
"ref": "fadbfe33303a76e25cb63401050439aa9b1a9c7f"
}
},
"symfony/monolog-bundle": {
"version": "3.10",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "3.7",
"ref": "aff23899c4440dd995907613c1dd709b6f59503f"
},
"files": [
"config/packages/monolog.yaml"
]
},
"symfony/notifier": {
"version": "7.0",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "5.0",
"ref": "178877daf79d2dbd62129dd03612cb1a2cb407cc"
},
"files": [
"config/packages/notifier.yaml"
]
},
"symfony/routing": {
"version": "7.0",
"recipe": {
@@ -114,6 +150,40 @@
"templates/base.html.twig"
]
},
"symfony/uid": {
"version": "7.2",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "7.0",
"ref": "0df5844274d871b37fc3816c57a768ffc60a43a5"
}
},
"symfony/ux-twig-component": {
"version": "2.23",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "2.13",
"ref": "67814b5f9794798b885cec9d3f48631424449a01"
},
"files": [
"config/packages/twig_component.yaml"
]
},
"symfony/web-profiler-bundle": {
"version": "7.0",
"recipe": {
"repo": "github.com/symfony/recipes",
"branch": "main",
"version": "6.1",
"ref": "e42b3f0177df239add25373083a564e5ead4e13a"
},
"files": [
"config/packages/web_profiler.yaml",
"config/routes/web_profiler.yaml"
]
},
"twig/extra-bundle": {
"version": "v3.8.0"
}
+100 -24
View File
@@ -1,27 +1,51 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
base64 (0.2.0)
bigdecimal (3.1.7)
bigdecimal (3.1.9)
colorator (1.1.0)
concurrent-ruby (1.2.3)
csv (3.3.0)
concurrent-ruby (1.3.5)
csv (3.3.2)
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
eventmachine (1.2.7)
ffi (1.16.3)
ffi (1.17.1)
ffi (1.17.1-aarch64-linux-gnu)
ffi (1.17.1-aarch64-linux-musl)
ffi (1.17.1-arm-linux-gnu)
ffi (1.17.1-arm-linux-musl)
ffi (1.17.1-arm64-darwin)
ffi (1.17.1-x86-linux-gnu)
ffi (1.17.1-x86-linux-musl)
ffi (1.17.1-x86_64-darwin)
ffi (1.17.1-x86_64-linux-gnu)
ffi (1.17.1-x86_64-linux-musl)
forwardable-extended (2.6.0)
google-protobuf (4.26.1)
google-protobuf (4.29.3)
bigdecimal
rake (>= 13)
google-protobuf (4.26.1-x86_64-linux)
google-protobuf (4.29.3-aarch64-linux)
bigdecimal
rake (>= 13)
google-protobuf (4.29.3-arm64-darwin)
bigdecimal
rake (>= 13)
google-protobuf (4.29.3-x86-linux)
bigdecimal
rake (>= 13)
google-protobuf (4.29.3-x86_64-darwin)
bigdecimal
rake (>= 13)
google-protobuf (4.29.3-x86_64-linux)
bigdecimal
rake (>= 13)
http_parser.rb (0.8.0)
i18n (1.14.4)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
jekyll (4.3.3)
jekyll (4.3.4)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
@@ -47,8 +71,8 @@ GEM
jekyll (>= 3.7, < 5.0)
jekyll-watch (2.2.1)
listen (~> 3.0)
kramdown (2.4.0)
rexml
kramdown (2.5.1)
rexml (>= 3.3.9)
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
liquid (4.0.4)
@@ -58,27 +82,79 @@ GEM
mercenary (0.4.0)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (5.0.5)
public_suffix (6.0.1)
rake (13.2.1)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
rb-inotify (0.11.1)
ffi (~> 1.0)
rexml (3.2.6)
rouge (4.2.1)
rexml (3.4.0)
rouge (4.5.1)
safe_yaml (1.0.5)
sass-embedded (1.76.0)
google-protobuf (>= 3.25, < 5.0)
rake (>= 13.0.0)
sass-embedded (1.76.0-x86_64-linux-gnu)
google-protobuf (>= 3.25, < 5.0)
sass-embedded (1.83.4)
google-protobuf (~> 4.29)
rake (>= 13)
sass-embedded (1.83.4-aarch64-linux-android)
google-protobuf (~> 4.29)
sass-embedded (1.83.4-aarch64-linux-gnu)
google-protobuf (~> 4.29)
sass-embedded (1.83.4-aarch64-linux-musl)
google-protobuf (~> 4.29)
sass-embedded (1.83.4-aarch64-mingw-ucrt)
google-protobuf (~> 4.29)
sass-embedded (1.83.4-arm-linux-androideabi)
google-protobuf (~> 4.29)
sass-embedded (1.83.4-arm-linux-gnueabihf)
google-protobuf (~> 4.29)
sass-embedded (1.83.4-arm-linux-musleabihf)
google-protobuf (~> 4.29)
sass-embedded (1.83.4-arm64-darwin)
google-protobuf (~> 4.29)
sass-embedded (1.83.4-riscv64-linux-android)
google-protobuf (~> 4.29)
sass-embedded (1.83.4-riscv64-linux-gnu)
google-protobuf (~> 4.29)
sass-embedded (1.83.4-riscv64-linux-musl)
google-protobuf (~> 4.29)
sass-embedded (1.83.4-x86_64-cygwin)
google-protobuf (~> 4.29)
sass-embedded (1.83.4-x86_64-darwin)
google-protobuf (~> 4.29)
sass-embedded (1.83.4-x86_64-linux-android)
google-protobuf (~> 4.29)
sass-embedded (1.83.4-x86_64-linux-gnu)
google-protobuf (~> 4.29)
sass-embedded (1.83.4-x86_64-linux-musl)
google-protobuf (~> 4.29)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
unicode-display_width (2.5.0)
webrick (1.8.1)
unicode-display_width (2.6.0)
webrick (1.9.1)
PLATFORMS
aarch64-linux
aarch64-linux-android
aarch64-linux-gnu
aarch64-linux-musl
aarch64-mingw-ucrt
arm-linux-androideabi
arm-linux-gnu
arm-linux-gnueabihf
arm-linux-musl
arm-linux-musleabihf
arm64-darwin
riscv64-linux-android
riscv64-linux-gnu
riscv64-linux-musl
ruby
x86-linux
x86-linux-gnu
x86-linux-musl
x86_64-cygwin
x86_64-darwin
x86_64-linux
x86_64-linux-android
x86_64-linux-gnu
x86_64-linux-musl
DEPENDENCIES
base64
@@ -92,4 +168,4 @@ DEPENDENCIES
webrick
BUNDLED WITH
2.5.6
2.6.3
+1 -1
View File
@@ -4,4 +4,4 @@
npm install --force
npm run build
bundle exec jekyll serve --livereload
```
```
+2 -2
View File
@@ -1,6 +1,6 @@
{
"dist/main.css": "/dist/main.27d36c82.css",
"dist/main.js": "/dist/main.513c5cd1.js",
"dist/main.css": "/dist/main.801e5ea3.css",
"dist/main.js": "/dist/main.36e31cce.js",
"dist/455.3a7b4474.css": "/dist/455.3a7b4474.css",
"dist/455.095e6545.js": "/dist/455.095e6545.js",
"dist/411.29cd993e.css": "/dist/411.29cd993e.css",
+32 -41
View File
@@ -1,7 +1,6 @@
## <i class="fa-duotone fa-list-radio"></i> Usage
To display a notification message, you can either use the `flash()` helper method or obtain an instance of `flasher` from the service container.
Then, before returning a view or redirecting, call the `success()` method and pass in the desired message to be displayed.
To show a notification message, you can use the `flash()` helper function or get an instance of `flasher` from the service container. Before you return a view or redirect, call one of the notification methods like `success()` and pass in the message you want to display.
{% assign id = '#/ PHPFlasher' %}
{% assign type = 'success' %}
@@ -24,7 +23,7 @@ class BookController
flash('{{ message }}');
// ... redirect or render the view
// ... redirect or render a view
}
/**
@@ -36,18 +35,16 @@ class BookController
$flasher->success('{{ site.data.messages["success"] | sample }}');
// ... redirect or render the view
// ... redirect or render a view
}
}
```
<br />
It's important to choose a message that is clear and concise, and that accurately reflects the outcome of the operation. <br />
In this case, `"Book has been created successfully!"` is already a good message,
but you may want to tailor it to fit the specific context and language of your application.
Choose a message that is clear and tells the user what happened. For example, `"Book has been created successfully!"` is a good message, but you can adjust it to fit your application's context and language.
> Using this package is actually pretty easy. Adding notifications to your application actually require only one line of code.
> Using this package is easy. You can add notifications to your application with just one line of code.
{% assign id = '#/ usage success' %}
{% assign type = 'success' %}
@@ -99,11 +96,10 @@ flash()->{{ type }}('{{ message }}');
---
These four methods `success()`, `error()`, `warning()`, `info()` are simply convenience shortcuts for the `flash()` method,
allowing you to specify the `type` and `message` in a single method call rather than having to pass both as separate arguments to the `flash()` method.
These four methods `success()`, `error()`, `warning()`, and `info()` are shortcuts for the `flash()` method. They let you specify the `type` and `message` in one method call instead of passing them separately to `flash()`.
```php
flash()->flash(string $type, string $message, string $title = null, array $options = [])
flash()->flash(string $type, string $message, array $options = [], string $title = null)
```
{% assign id = '#/ usage flash' %}
@@ -118,22 +114,19 @@ flash()->flash(string $type, string $message, string $title = null, array $optio
flash()->flash('{{ type }}', '{{ message }}');
```
| param | description |
|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `$type` | Notification type : <span class="text-white bg-green-600 px-2 py-1 rounded">success</span>, <span class="text-white bg-red-600 px-2 py-1 rounded">error</span>, <span class="text-white bg-yellow-600 px-2 py-1 rounded">warning</span>, <span class="text-white bg-blue-600 px-2 py-1 rounded">info</span> |
| `$message` | The body of the message you want to deliver to your user. This may contain HTML. If you add links, be sure to add the appropriate classes for the framework you are using. |
| `$title` | The notification title, Can also include HTML |
| `$options` | Custom options for javascript libraries (toastr, noty, notyf ...etc) |
| Parameter | Description |
|------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `$type` | Notification type: <span class="text-white bg-green-600 px-2 py-1 rounded">success</span>, <span class="text-white bg-red-600 px-2 py-1 rounded">error</span>, <span class="text-white bg-yellow-600 px-2 py-1 rounded">warning</span>, <span class="text-white bg-blue-600 px-2 py-1 rounded">info</span> |
| `$message` | The message you want to show to the user. This can include HTML. If you add links, make sure to add the right classes for your framework. |
| `$title` | The notification title. Can also include HTML. |
| `$options` | Custom options for JavaScript libraries (toastr, noty, notyf, etc.). |
---
<p id="method-options"><a href="#method-options" class="anchor"><i class="fa-duotone fa-link"></i> options</a></p>
The `options()` method allows you to set multiple options at once by passing an array of `key-value` pairs,
while the `option()` method allows you to set a single option by specifying its name and value as separate arguments. <br /><br />
The optional `$append` argument for the `options()` method can be used to specify whether the new options should be appended to any existing options,
or whether they should overwrite them.
The `options()` method lets you set multiple options at once by passing an array of key-value pairs. The `option()` method lets you set a single option by specifying its name and value. The `$append` argument for `options()` decides whether the new options should be added to existing ones (`true`) or replace them (`false`).
```php
flash()->options(array $options, bool $append = true);
@@ -160,7 +153,7 @@ flash()
<p id="method-option"><a href="#method-option" class="anchor"><i class="fa-duotone fa-link"></i> option</a></p>
Set a single option by specifying its name and value as separate arguments.
To set a single option:
```php
flash()->option(string $option, mixed $value);
@@ -185,7 +178,7 @@ flash()
<p id="method-priority"><a href="#method-priority" class="anchor"><i class="fa-duotone fa-link"></i> priority</a></p>
Sets the priority of a flash message, the highest priority will be displayed first.
Set the priority of a flash message. Messages with higher priority appear first.
```php
flash()->priority(int $priority);
@@ -246,17 +239,17 @@ flash()
->info('{{ infoMessage }}');
```
| param | description |
|-------------|--------------------------------------------------------------------------------------------|
| `$priority` | The priority of the notification, the higher the priority, the sooner it will be displayed |
| param | description |
|-------------|-------------------------------------------------------------------|
| `$priority` | The priority of the notification. Higher numbers are shown first. |
---
<p id="method-hops"><a href="#method-hops" class="anchor"><i class="fa-duotone fa-link"></i> hops</a></p>
This method sets the number of requests that the flash message should persist for. By default, flash messages are only displayed for a single request and are then discarded. By setting the number of hops, the flash message will be persisted for multiple requests.
The `hops()` method sets how many requests the flash message should last for. By default, flash messages show for one request. Setting the number of hops makes the message stay for multiple requests.
As an example, with a multi-page form, you may want to store messages until all pages have been filled.
For example, in a multi-page form, you might want to keep messages until all pages are completed.
{% assign id = '#/ usage hops' %}
{% assign type = site.data.messages.types | sample %}
@@ -274,16 +267,15 @@ flash()
->{{ type }}('{{ message }}');
```
| param | description |
|---------|---------------------------------------------------------------|
| `$hops` | indicate how many requests the flash message will persist for |
| param | description |
|---------|-------------------------------------------------------|
| `$hops` | Number of requests the flash message will persist for |
---
<p id="method-translate"><a href="#method-translate" class="anchor"><i class="fa-duotone fa-link"></i> translate</a></p>
This method sets the `locale` to be used for the translation of the flash message. If a non-null value is provided,
the flash message will be translated into the specified language. If null is provided, the **default** `locale` will be used.
The `translate()` method sets the `locale` for translating the flash message. If you provide a locale, the message will be translated to that language. If you pass `null`, it uses the default locale.
```php
flash()->translate(string $locale = null);
@@ -320,18 +312,17 @@ flash()
->{{ type }}('Your request was processed successfully.', 'Congratulations!');
```
| param | description |
|-----------|------------------------------------------------------------------------------|
| `$locale` | The locale to be used for the translation, or null to use the default locale |
| param | description |
|-----------|--------------------------------------------------------------|
| `$locale` | The locale to use for translation, or `null` for the default |
It is **important** to note that the `translate()` method only sets the locale to be used for the translation of the flash message.
It does not actually perform the translation itself.
**Note:** The `translate()` method only sets the locale. It doesn't translate the message by itself.
In order to translate the flash message, you will need to provide the appropriate translation keys in your translation files.
To translate the message, you need to add the translation keys in your translation files.
{% if page.framework == 'laravel' %}
In the above example, to translate the flash message into `Arabic`, you will need to add the following keys to the `resources/lang/ar/messages.php` file:
For example, to translate the message into Arabic, add these keys to `resources/lang/ar/messages.php`:
```php
return [
@@ -342,7 +333,7 @@ return [
{% elsif page.framework == 'symfony' %}
In the above example, to translate the flash message into `Arabic`, you will need to add the following keys to the `translations/messages.ar.yaml` file:
For example, to translate the message into Arabic, add these keys to `translations/messages.ar.yaml`:
```yaml
Your request was processed successfully.: 'تمت العملية بنجاح.'
+8 -9
View File
@@ -20,7 +20,7 @@
<div class="flex items-center flex-no-shrink pt-1">
<div class="flex items-center">
<span class="pr-2 font-normal leading-none text-3xl text-indigo-900 hidden sm:block">
<img class="fill-current h-8 mr-2" src="/static/images/php-flasher-logo.svg" />
<img class="fill-current h-8 mr-2" src="/static/images/php-flasher-logo.svg" alt="PHPFlasher Logo" />
{% for version in site.data.project.versions %}
<a href="{{ version[1] }}" class="{% if forloop.first %}text-white bg-indigo-500{% else %}text-indigo-600{% endif %} p-1 rounded text-xs relative text-grey-dark hover:bg-indigo-500 hover:scale-110 hover:text-white" style="top: -20px;">{{ version[0] }}</a>
{% endfor %}
@@ -46,7 +46,7 @@
<ul class="list-reset mb-8">
{% for link in section[1] %}
<li class="{% if page.url == link[1] %}bg-indigo-500 {% endif %}px-6 rounded">
<a class="leading-loose text-md inline-block w-full {% if page.url == link[1] %}text-white{% else %}text-gray-900{% endif %}" href="{{ link[1] }}">{{ link[0] }}</a>
<a href="{{ link[1] }}" class="leading-loose text-md inline-block w-full {% if page.url == link[1] %}text-white{% else %}text-gray-900{% endif %}">{{ link[0] }}</a>
</li>
{% endfor %}
</ul>
@@ -58,13 +58,12 @@
</div>
<blockquote>
<p>
If you find <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> useful,
we would greatly appreciate your support in the form of a <strong>star</strong> rating ⭐
on <a href="https://github.com/php-flasher/php-flasher"><i class="fab fa-github text-black"></i> GitHub</a>
or by sharing the project on Twitter <a href="http://twitter.com/share?text=I%20really%20like%20this%20nice%20PHP%20package%2C%20that%20allows%20you%20to%20implement%20flash%20notifications%20in%20your%20app%20fast%20%F0%9F%9A%80%0A%0A%E2%86%92%20https%3A%2F%2Fphp-flasher.io%20by%20%40yoeunes%0A%0A%23php%20%23laravel%20%23symfony%20%23opensource"><i class="fab fa-twitter"></i> click here</a>.
Your feedback helps us keep the package up-to-date and well-maintained. <strong>Thank you</strong> <i class="fa-solid fa-heart text-red-600"></i>
</p>
<p>
If you find <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> useful,
please consider giving it a <strong>star</strong> on <a href="https://github.com/php-flasher/php-flasher"><i class="fab fa-github text-black"></i> GitHub</a> 😊.
If you spot any typos or have suggestions, feel free to contribute to the documentation 📝.
Your feedback helps keep the project up-to-date and well-maintained. <strong>Thank you</strong> <i class="fa-solid fa-heart text-red-600"></i>
</p>
</blockquote>
<hr>
+2 -2
View File
@@ -2,10 +2,10 @@
"entrypoints": {
"main": {
"css": [
"/dist/main.27d36c82.css"
"/dist/main.801e5ea3.css"
],
"js": [
"/dist/main.513c5cd1.js"
"/dist/main.36e31cce.js"
]
}
}
-2
View File
File diff suppressed because one or more lines are too long
+2
View File
File diff suppressed because one or more lines are too long
-2
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
+518 -2468
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -1,6 +1,6 @@
{
"name": "@flasher/docs",
"version": "2.0.0",
"version": "2.1.0",
"license": "MIT",
"scripts": {
"build": "cross-env NODE_ENV=production encore production --progress",
@@ -16,12 +16,12 @@
"@flasher/flasher-sweetalert": "file:../src/SweetAlert/Prime/Resources",
"@flasher/flasher-toastr": "file:../src/Toastr/Prime/Resources",
"@hotwired/stimulus": "^3.2.2",
"@symfony/stimulus-bridge": "^3.2.2",
"@symfony/webpack-encore": "^4.6.1",
"@symfony/stimulus-bridge": "^3.2.3",
"@symfony/webpack-encore": "^5.0.1",
"noty": "^3.2.0-beta-deprecated",
"notyf": "^3.10.0",
"prismjs": "^1.29.0",
"sweetalert2": "^11.11.0",
"sweetalert2": "^11.6.13",
"toastr": "^2.1.4"
},
"devDependencies": {
@@ -30,7 +30,7 @@
"node-ray": "^2.1.2",
"postcss-import": "^16.1.0",
"postcss-loader": "^7.3.4",
"tailwindcss": "^3.4.3",
"tailwindcss": "^3.4.17",
"webpack-notifier": "^1.15.0"
},
"browserslist": [
+20 -18
View File
@@ -1,6 +1,6 @@
---
permalink: /
description: PHPFlasher is a robust, open-source tool for seamlessly adding flash messages to Laravel or Symfony projects, aimed at improving user interaction and feedback with minimal developer effort.
description: PHPFlasher is an open-source tool that makes it easy to add flash messages to your Laravel or Symfony projects. Improve user interaction with minimal effort using simple, customizable notifications.
data-controller: flasher
---
@@ -33,39 +33,41 @@ data-controller: flasher
## <i class="fa-duotone fa-list-radio"></i> Introduction
<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> is a powerful, community-driven, open-source project designed to enhance your web applications by providing an intuitive way to display flash messages. These messages serve as immediate feedback for user actions, significantly improving user experience by confirming actions like form submissions, warnings, or errors.
<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> is an open-source tool that helps you add flash messages to your web applications. Flash messages are short messages that give feedback to users after they do something, like submitting a form or encountering an error. These messages improve the user experience by letting users know what happened.
Flash messages are crucial for interactive applications, and <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> makes implementing them in <i class="fa-brands fa-laravel text-red-900 fa-xl"></i> <strong>Laravel</strong> or <i class="fa-brands fa-symfony text-black fa-xl"></i> <strong>Symfony</strong> projects straightforward. With support for session-based message storage, <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> ensures that messages can be easily set and then retrieved for display on subsequent pages, without complex setup.
Flash messages are important for interactive applications. **<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>** makes it easy to add them to **<i class="fa-brands fa-laravel text-red-900 fa-xl"></i> Laravel** or **<i class="fa-brands fa-symfony text-black fa-xl"></i> Symfony** projects. It uses sessions to store messages, so you can set a message on one page and show it on another, without complex setup.
---
### <i class="fa-duotone fa-list-radio"></i> Notification Types
<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> can handle a variety of notification types to suit different feedback scenarios:
**<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>** supports different types of notifications:
> <div class="mt-2"><span class="text-green-700"><i class="fa-solid fa-circle-check fa-xl"></i> success : </span> indicates successful completion of an action.</div>
> <div class="mt-2"><span class="text-blue-600"><i class="fa-solid fa-circle-info fa-xl"></i> info : </span> provides informational messages to users.</div>
> <div class="mt-2"><span class="text-yellow-600"><i class="fa-solid fa-circle-exclamation fa-xl"></i> warning : </span> alerts users to potential issues that are not errors.</div>
> <div class="mt-2"><span class="text-red-600"><i class="fa-solid fa-circle-xmark fa-xl"></i> error : </span> notifies users of errors or problems encountered.</div>
> <div class="mt-2"><span class="text-green-700"><i class="fa-solid fa-circle-check fa-xl"></i> Success</span>: Shows when something works well.</div>
> <div class="mt-2"><span class="text-blue-600"><i class="fa-solid fa-circle-info fa-xl"></i> Info</span>: Gives information to the user.</div>
> <div class="mt-2"><span class="text-yellow-600"><i class="fa-solid fa-circle-exclamation fa-xl"></i> Warning</span>: Alerts about potential issues.</div>
> <div class="mt-2"><span class="text-red-600"><i class="fa-solid fa-circle-xmark fa-xl"></i> Error</span>: Tells the user about an error.</div>
---
## <i class="fa-duotone fa-list-radio"></i> Why <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> ?
## <i class="fa-duotone fa-list-radio"></i> Why **<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>**?
- **Broad Library Support**: PHPFlasher integrates with several popular notification libraries, including [toastr.js](/library/toastr/), [SweetAlert 2](/library/sweetalert/), [Noty](/library/noty/), and [Notyf](/library/notyf/).
- **Ease of Use**: Designed with all levels of developers in mind, from beginners to experienced professionals.
- **Flexibility**: Offers extensive customization options for notification styling and behaviors.
- **Framework Compatibility**: Seamlessly integrates with <i class="fa-brands fa-laravel text-red-900 fa-xl"></i> <strong>Laravel</strong> and <i class="fa-brands fa-symfony text-black fa-xl"></i> <strong>Symfony</strong>, with options for custom adapter creation.
- **Developer Friendly**: Features PHPStorm autocomplete for easier coding and integration.
- **Supports Many Libraries**: Works with popular notification libraries like [toastr.js](/library/toastr/), [SweetAlert 2](/library/sweetalert/), [Noty](/library/noty/), and [Notyf](/library/notyf/).
- **Easy to Use**: Designed for all developers, from beginners to experts.
- **Flexible**: You can customize how the notifications look and behave.
- **Framework Compatibility**: Integrates smoothly with <i class="fa-brands fa-laravel text-red-900 fa-xl"></i> <strong>Laravel</strong> and <i class="fa-brands fa-symfony text-black fa-xl"></i> <strong>Symfony</strong>. You can also create custom adapters.
- **Developer-Friendly**: Features like autocomplete in PHPStorm make coding easier.
---
## <i class="fa-duotone fa-list-radio"></i> Getting Started
Dive into <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> with our straightforward guides and documentation to seamlessly integrate flash messaging into your projects:
Start using **<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>** with our easy guides:
- [**Symfony Guide**](/Symfony/)
- [**Laravel Guide**](/Laravel/)
- [**Symfony Guide**](/symfony/)
- [**Laravel Guide**](/laravel/)
- [**Livewire Guide**](/livewire/)
- [**Inertia Guide**](/inertia/)
- [**Toastr Library**](/library/toastr/)
- [**Noty Library**](/library/noty/)
- [**Notyf Library**](/library/notyf/)
@@ -73,4 +75,4 @@ Dive into <strong><span class="text-indigo-900">PHP<span class="text-indigo-500"
## <i class="fa-duotone fa-list-radio"></i> Contributions
<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> thrives on community contributions. Your feedback, code contributions, and feature suggestions are invaluable to us. Explore our [GitHub repository](https://github.com/php-flasher/php-flasher) to see how you can become part of the <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> community. Let's build something great together <i class="fa-solid fa-heart text-red-600"></i>!
**<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>** grows with help from the community. We welcome your feedback, code contributions, and ideas. Check out our [GitHub repository](https://github.com/php-flasher/php-flasher) to join the **<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>** community. Let's build something great together! <i class="fa-solid fa-heart text-red-600"></i>
+7 -7
View File
@@ -1,16 +1,16 @@
---
permalink: /inertia/
title: Inertia
description: Easily add flash notification messages to your Inertia application with PHPFlasher. Follow our step-by-step guide to install and use the library in your project, and start engaging and informing your users with powerful flash messages.
description: Discover how to integrate flash notifications into your Inertia.js application with PHPFlasher. Follow this guide to set up the library and enhance your user interface with dynamic messages.
---
<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> offers a solid integration with Inertia.js
<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> works well with Inertia.js.
## <i class="fa-duotone fa-list-radio"></i> Installation
To integrate <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> with Inertia.js, follow the same installation steps as for the [Laravel Installation](/laravel) package.
To use **<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>** with Inertia.js, install it the same way as in the [Laravel Installation](/laravel) guide.
Additionally, include `@flasher/flasher` in your package.json by adding the following line:
Also, add `@flasher/flasher` to your `package.json`:
```json
"@flasher/flasher": "file:vendor/php-flasher/flasher/Resources"
@@ -26,7 +26,7 @@ npm install --force
## <i class="fa-duotone fa-list-radio"></i> Usage
Dispatch `notifications` from your `HandleInertiaRequests` middleware shared data.
Send `notifications` from your `HandleInertiaRequests` middleware.
```php
<?php
@@ -45,7 +45,7 @@ class HandleInertiaRequests extends Middleware
---
Then render your `notifications` from your `Layout.vue` file like the following:
Then, display your `notifications` in your `Layout.vue` file:
```html
// resources/js/Shared/Layout.vue
@@ -65,7 +65,7 @@ export default {
</script>
```
All you have to do now, is to trigger you notification from anywhere in your application.
Now, you can trigger notifications from anywhere in your application.
```php
<?php
+1 -1
View File
@@ -1,7 +1,7 @@
---
permalink: /installation/
title: Installation
description: Install only the specific components you need for your project with PHPFlasher, a modular PHP library for displaying flash notification messages. Simply include the library in your composer.json file and run the composer install command to get started.
description: Install PHPFlasher in your project easily. Its modular, so you can install only the parts you need. Just include the library in your composer.json file and run composer install to get started.
---
**<span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span>** is modular and consists of multiple libraries,
+84 -74
View File
@@ -2,15 +2,15 @@
permalink: /laravel/
title: Laravel
handler: flasher
description: Easily add flash notification messages to your Laravel application with PHPFlasher. Follow our step-by-step guide to install and use the library in your project, and start engaging and informing your users with powerful flash messages.
description: Add flash notifications to your Laravel application with PHPFlasher. Follow our step-by-step guide to install and use the library, and start informing your users with powerful flash messages.
framework: laravel
---
## <i class="fa-duotone fa-list-radio"></i> Requirements
<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> offers a seamless way to incorporate flash notifications in <i class="fa-brands fa-laravel text-red-900 fa-xl"></i> <strong>Laravel</strong> projects, enhancing user feedback with minimal setup.
**<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>** helps you easily add flash notifications to your **<i class="fa-brands fa-laravel text-red-900 fa-xl"></i> Laravel** projects, improving user feedback with minimal setup.
Requirements for using <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> with Laravel:
To use **<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>** with Laravel, you need:
> <i class="fa-brands fa-php fa-2xl text-blue-900 mr-1 mb-1"></i> **PHP** v8.2 or higher
> <i class="fa-brands fa-laravel fa-2xl text-red-900 mr-1 ml-4"></i> **Laravel** v11.0 or higher
@@ -19,13 +19,15 @@ Requirements for using <strong><span class="text-indigo-900">PHP<span class="tex
## <i class="fa-duotone fa-list-radio"></i> Installation
<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>'s modular design lets you select and install only the components your project needs.
**PHPFlasher** is modular, so you can install only the parts you need.
Run this command to install it:
```shell
composer require php-flasher/flasher-laravel
```
After installation, you need to run another command to set up the necessary assets for <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>:
After installing, run this command to set up the required assets:
```shell
php artisan flasher:install
@@ -39,43 +41,42 @@ php artisan flasher:install
## <i class="fa-duotone fa-list-radio"></i> Configuration
As optional, if you want to modify the default configuration, you can publish the configuration file:
If you want to change the default settings, you can publish the configuration file:
```bash
php artisan flasher:install --config
```
The configuration file will be located at `config/flasher.php` and will have the following content:
This will create a file at `config/flasher.php` with the following content:
```php
<?php // config/flasher.php
return [
// Default notification library (e.g., 'flasher', 'toastr', 'noty', etc.)
// Default notification library (e.g., 'flasher', 'toastr', 'noty', 'notyf', 'sweetalert')
'default' => 'flasher',
// Path to the main JavaScript file of PHPFlasher
// Path to the main PHPFlasher JavaScript file
'main_script' => '/vendor/flasher/flasher.min.js',
// Path to the stylesheets for PHPFlasher notifications
// List of CSS files to style your notifications
'styles' => [
'/vendor/flasher/flasher.min.css',
],
// Enable translation of PHPFlasher messages using Laravel's translator service
'translate' => true,
// Set global options for all notifications (optional)
// 'options' => [
// 'timeout' => 5000, // Time in milliseconds before the notification disappears
// 'position' => 'top-right', // Where the notification appears on the screen
// ],
// Automatically inject PHPFlasher assets in HTML response
// Automatically inject JavaScript and CSS assets into your HTML pages
'inject_assets' => true,
// Global options
'options' => [
'timeout' => 5000, // in milliseconds
'position' => 'top-right',
],
// Enable message translation using Laravel's translation service
'translate' => true,
// Configuration for the flash bag (converting Laravel flash messages)
// Map Laravel session keys to PHPFlasher types
// Map Laravel flash message keys to notification types
'flash_bag' => [
'success' => ['success'],
'error' => ['error', 'danger'],
@@ -83,22 +84,33 @@ return [
'info' => ['info', 'notice', 'alert'],
],
// Filter criteria for notifications (e.g., limit number, types)
'filter' => [
'limit' => 5, // Limit the number of displayed notifications
],
// Set criteria to filter which notifications are displayed (optional)
// 'filter' => [
// 'limit' => 5, // Maximum number of notifications to show at once
// ],
// Define notification presets to simplify notification creation (optional)
// 'presets' => [
// 'entity_saved' => [
// 'type' => 'success',
// 'title' => 'Entity saved',
// 'message' => 'Entity saved successfully',
// ],
// ],
];
```
---
## <i class="fa-duotone fa-list-radio"></i> Presets
You can create a preset for a custom notification that you want to reuse in multiple places by adding a presets entry in the configuration file.
You can create a preset for a custom notification that you want to reuse in multiple places by adding a `presets` entry in the configuration file.
> You can think of a preset as a pre-defined message that you can use in multiple locations. <br>
> A preset is like a pre-defined message you can use in many places.
For example, you can create a preset named `entity_saved` in the configuration file and then use
For example, create a preset named `entity_saved`:
{% assign id = '#/ laravel preset' %}
{% assign type = 'success' %}
@@ -121,7 +133,7 @@ return [
];
```
To use the preset, you can call the `preset()` method and pass the name of the preset as the first argument:
To use the preset, call the `preset()` method and pass the name of the preset:
```php
{{ id }}
@@ -145,7 +157,7 @@ class BookController
<p id="preset-variables"><a href="#preset-variables" class="anchor"><i class="fa-duotone fa-link"></i> Variables</a></p>
Presets can also contain variables that can be substituted by using the translation system. Take the following example where you have a preset showing a personalised welcome message to the user.
Presets can also have variables that you can replace using the translation system. For example, you can have a preset that shows a personalized welcome message.
```php
<?php // config/flasher.php
@@ -160,7 +172,7 @@ return [
];
```
In the translations file you can define `welcome_back_user` with the message containing the variable `:username`.
In your translation file, define `welcome_back_user` with a message containing the variable `:username`.
```php
<?php // /resources/lang/vendor/flasher/en/messages.php
@@ -170,7 +182,7 @@ return [
];
```
If you want to substitute the `:username` in the above translation with a username in the controller, you can achieve this by passing an array of values to be substituted as the second argument.
To replace `:username` with the actual username in your controller, pass an array with the values to substitute as the second argument:
```php
class BookController
@@ -186,10 +198,9 @@ class BookController
## <i class="fa-duotone fa-list-radio"></i> RTL support
<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> makes it easy to incorporate <i class="fa-duotone fa-signs-post text-indigo-900 mr-1 fa-lg"></i> **right-to-left** languages like `Arabic` or `Hebrew`.
it automatically detects the text direction and handles the necessary adjustments for you.
<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> makes it easy to use <i class="fa-duotone fa-signs-post text-indigo-900 mr-1 fa-lg"></i> **right-to-left** languages like `Arabic` or `Hebrew`. It automatically detects the text direction and adjusts accordingly.
Simply make sure the translation service is enabled and let <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> handle the rest.
Just make sure the translation service is enabled, and <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> will handle the rest.
{% assign id = '#/ phpflasher rtl' %}
{% assign type = 'success' %}
@@ -210,14 +221,13 @@ flash()
## <i class="fa-duotone fa-list-radio"></i> Translation
<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> allows you to translate your notification `messages` and `presets`, it comes with `Arabic`, `English`, `French`, `German`, `Spanish`, `Portuguese`, `Russian`, and `Chinese` translations out of the box. but you can easily add your own translations.
<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> lets you translate your notification `messages` and `presets`. It comes with translations for `Arabic`, `English`, `French`, `German`, `Spanish`, `Portuguese`, `Russian`, and `Chinese`. You can also add your own translations.
For example, to override the `English` translation strings for <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>, you can create a language file at the following location:
**`/resources/lang/vendor/flasher/en/messages.php`**.
To override the `English` translations for <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>, create a file at `/resources/lang/vendor/flasher/en/messages.php`.
In this file, you should **only** define the translation strings you want to override. Any translation strings that you don't override will still be loaded from <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>'s original language files.
In this file, define only the translation strings you want to change. Any strings you don't override will use <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>'s default translations.
Here are examples of the default translation keys for `Arabic`, `English`, and `French` in <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>:
Here are examples of the default translation keys for `Arabic`, `English`, and `French`:
```php
<?php // /resources/lang/vendor/flasher/ar/messages.php
@@ -273,7 +283,7 @@ return [
];
```
> These translation files facilitate localizing notifications to match user preferences and ensure that your applications can communicate effectively across different linguistic contexts.
> These translation files help you localize notifications to match user preferences, so your application can communicate effectively in different languages.
{% assign id = '#/ laravel arabic translations' %}
{% assign successMessage = 'تم إنشاء الملف' %}
@@ -282,33 +292,33 @@ return [
{% assign infoMessage = 'سيتم تحديث هذه الصفحة في غضون 10 دقائق.' %}
<script type="text/javascript">
messages["{{ id }}"] = [
messages['{{ id }}'] = [
{
handler: "flasher",
type: "success",
message: "{{ successMessage }}",
title: "نجاح",
handler: 'flasher',
type: 'success',
message: '{{ successMessage }}',
title: 'نجاح',
options: {},
},
{
handler: "flasher",
type: "error",
message: "{{ errorMessage }}",
title: "خطأ",
handler: 'flasher',
type: 'error',
message: '{{ errorMessage }}',
title: 'خطأ',
options: {},
},
{
handler: "flasher",
type: "warning",
message: "{{ warningMessage }}",
title: "تحذير",
handler: 'flasher',
type: 'warning',
message: '{{ warningMessage }}',
title: 'تحذير',
options: {},
},
{
handler: "flasher",
type: "info",
message: "{{ infoMessage }}",
title: "معلومة",
handler: 'flasher',
type: 'info',
message: '{{ infoMessage }}',
title: 'معلومة',
options: {},
},
@@ -338,33 +348,33 @@ flash()->info('{{ infoMessage }}');
{% assign infoMessage = "Cette page sera mise à jour dans 10 minutes."%}
<script type="text/javascript">
messages["{{ id }}"] = [
messages['{{ id }}'] = [
{
handler: "flasher",
type: "success",
message: "{{ successMessage }}",
title: "Succès",
handler: 'flasher',
type: 'success',
message: '{{ successMessage }}',
title: 'Succès',
options: {},
},
{
handler: "flasher",
type: "error",
message: "{{ errorMessage }}",
title: "Erreur",
handler: 'flasher',
type: 'error',
message: '{{ errorMessage }}',
title: 'Erreur',
options: {},
},
{
handler: "flasher",
type: "warning",
message: "{{ warningMessage }}",
title: "Avertissement",
handler: 'flasher',
type: 'warning',
message: '{{ warningMessage }}',
title: 'Avertissement',
options: {},
},
{
handler: "flasher",
type: "info",
message: "{{ infoMessage }}",
title: "Information",
handler: 'flasher',
type: 'info',
message: '{{ infoMessage }}',
title: 'Information',
options: {},
},
+7 -3
View File
@@ -1,7 +1,7 @@
---
permalink: /library/noty/
title: Noty
description: Elevate your user experience with Noty, a popular JavaScript library for creating customizable, stylish notification messages. Easy to install and use, Noty is perfect for any project that wants to engage and inform users in a dynamic way.
description: Enhance your user experience with Noty, a JavaScript library for creating customizable notification messages. Learn how to use Noty with PHPFlasher to display stylish notifications in your project.
handler: noty
data-controller: noty
---
@@ -22,6 +22,8 @@ php artisan flasher:install
<p id="laravel-configuration"><a href="#laravel-configuration" class="anchor"><i class="fa-duotone fa-link"></i> Configuration</a></p>
> <strong>Note:</strong> The configuration settings below are the default ones. You only need to change them if you want to customize the default behavior.
```php
<?php // config/flasher.php
@@ -38,7 +40,7 @@ return [
],
'options' => [
// Optional: Add global options here
'layout' => 'topRight'
// 'layout' => 'topRight'
],
],
],
@@ -62,6 +64,8 @@ php bin/console flasher:install
<p id="symfony-configuration"><a href="#symfony-configuration" class="anchor"><i class="fa-duotone fa-link"></i> Configuration</a></p>
> <strong>Note:</strong> The configuration settings below are the default ones. You only need to change them if you want to customize the default behavior.
```yaml
# config/packages/flasher.yaml
@@ -76,7 +80,7 @@ flasher:
- '/vendor/flasher/mint.css'
options:
# Optional: Add global options here
layout: topRight
# layout: topRight
```
---
+7 -3
View File
@@ -1,7 +1,7 @@
---
permalink: /library/notyf/
title: Notyf
description: Add lightweight, customizable notification messages to your web projects with Notyf, a popular JavaScript library. With a focus on simplicity and accessibility, Notyf is easy to install and use, making it a great choice for any project that wants to engage and inform users.
description: Add lightweight, customizable notifications to your web projects with Notyf. This guide shows you how to integrate Notyf with PHPFlasher to engage and inform your users effectively.
handler: notyf
data-controller: notyf
---
@@ -23,6 +23,8 @@ php artisan flasher:install
<p id="laravel-configuration"><a href="#laravel-configuration" class="anchor"><i class="fa-duotone fa-link"></i> Configuration</a></p>
> <strong>Note:</strong> The configuration settings below are the default ones. You only need to change them if you want to customize the default behavior.
```php
<?php // config/flasher.php
@@ -37,7 +39,7 @@ return [
],
'options' => [
// Optional: Add global options here
'dismissible' => true,
// 'dismissible' => true,
],
],
],
@@ -60,6 +62,8 @@ php bin/console flasher:install
<p id="symfony-configuration"><a href="#symfony-configuration" class="anchor"><i class="fa-duotone fa-link"></i> Configuration</a></p>
> <strong>Note:</strong> The configuration settings below are the default ones. You only need to change them if you want to customize the default behavior.
```yaml
# config/packages/flasher.yaml
@@ -72,7 +76,7 @@ flasher:
- '/vendor/flasher/flasher-notyf.min.css'
options:
# Optional: Add global options here
dismissible: true
# dismissible: true
```
---
+7 -3
View File
@@ -1,7 +1,7 @@
---
permalink: /library/sweetalert/
title: Sweetalert
description: Add beautiful, customizable alert messages to your web projects with SweetAlert2, a popular JavaScript library. Easy to install and use, SweetAlert2 is perfect for any project that wants to engage and inform users in a visually appealing way.
description: Integrate beautiful alert messages into your web projects with SweetAlert2. This guide demonstrates how to use SweetAlert2 with PHPFlasher to inform users in a visually appealing way.
handler: sweetalert
data-controller: sweetalert
---
@@ -22,6 +22,8 @@ php artisan flasher:install
<p id="laravel-configuration"><a href="#laravel-configuration" class="anchor"><i class="fa-duotone fa-link"></i> Configuration</a></p>
> <strong>Note:</strong> The configuration settings below are the default ones. You only need to change them if you want to customize the default behavior.
```php
<?php // config/flasher.php
@@ -37,7 +39,7 @@ return [
],
'options' => [
// Optional: Add global options here
'position' => 'center'
// 'position' => 'center'
],
],
],
@@ -61,6 +63,8 @@ php bin/console flasher:install
<p id="symfony-configuration"><a href="#symfony-configuration" class="anchor"><i class="fa-duotone fa-link"></i> Configuration</a></p>
> <strong>Note:</strong> The configuration settings below are the default ones. You only need to change them if you want to customize the default behavior.
```yaml
# config/packages/flasher.yaml
@@ -74,7 +78,7 @@ flasher:
- '/vendor/flasher/sweetalert2.min.css'
options:
# Optional: Add global options here
position: center
# position: center
```
---
+7 -3
View File
@@ -1,7 +1,7 @@
---
permalink: /library/toastr/
title: Toastr
description: Easily add customizable, stylish notification messages to your web projects with Toastr, a popular JavaScript library. With a focus on simplicity and flexibility, Toastr is easy to install and use, making it a great choice for any project that wants to engage and inform users.
description: Use Toastr with PHPFlasher to add stylish notifications to your web projects. Improve user engagement with easy-to-use, customizable notification messages.
handler: toastr
data-controller: toastr
---
@@ -22,6 +22,8 @@ php artisan flasher:install
<p id="laravel-configuration"><a href="#laravel-configuration" class="anchor"><i class="fa-duotone fa-link"></i> Configuration</a></p>
> <strong>Note:</strong> The configuration settings below are the default ones. You only need to change them if you want to customize the default behavior.
```php
<?php // config/flasher.php
@@ -38,7 +40,7 @@ return [
],
'options' => [
// Optional: Add global options here
'closeButton' => true
// 'closeButton' => true
],
],
],
@@ -63,6 +65,8 @@ php bin/console flasher:install
<p id="symfony-configuration"><a href="#symfony-configuration" class="anchor"><i class="fa-duotone fa-link"></i> Configuration</a></p>
> <strong>Note:</strong> The configuration settings below are the default ones. You only need to change them if you want to customize the default behavior.
```yaml
# config/packages/flasher.yaml
@@ -77,7 +81,7 @@ flasher:
- '/vendor/flasher/toastr.min.css'
options:
# Optional: Add global options here
closeButton: true
# closeButton: true
```
---
+8 -9
View File
@@ -1,11 +1,11 @@
---
permalink: /livewire/
title: Livewire
description: Learn how to seamlessly integrate flash notification messages into your Livewire application with PHPFlasher. Follow our step-by-step guide to install and use the library in your project, and start engaging and informing your users with powerful flash messages.
description: Learn how to add flash notifications to your Livewire application using PHPFlasher. This guide walks you through installation and usage, so you can engage your users with informative messages.
adapter: flasher
---
<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> provides a seamless integration with Livewire v3.
**<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>** works seamlessly with Livewire v3.
## <i class="fa-duotone fa-list-radio"></i> Requirements
@@ -16,13 +16,13 @@ adapter: flasher
## <i class="fa-duotone fa-list-radio"></i> Installation
To integrate <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> with Livewire, follow the same installation steps as for the [Laravel Installation](/laravel) package.
To use **<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>** with Livewire, follow the same installation steps as in the [Laravel Installation](/laravel) guide.
```shell
composer require php-flasher/flasher-laravel
```
After installation, you need to run another command to set up the necessary assets for <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>:
After installing, run this command to set up the required assets:
```shell
php artisan flasher:install
@@ -64,7 +64,7 @@ class UserComponent extends Component
## <i class="fa-duotone fa-list-radio"></i> Events
For sweetalert you can listen to `sweetalert:confirmed`, `sweetalert:denied` and `sweetalert:dismissed` from withing you component
For SweetAlert, you can listen to `sweetalert:confirmed`, `sweetalert:denied`, and `sweetalert:dismissed` events within your component.
<script type="text/javascript">
messages["#/ livewire events"] = {
@@ -125,7 +125,7 @@ class UserComponent extends Component
### <i class="fa-duotone fa-list-radio"></i> event handlers context
Every listener method accept an **array $payload** parameter which contain the following data :
Each listener method accepts an **array $payload** parameter, which contains:
```php
public function sweetalertConfirmed(array $payload)
@@ -135,6 +135,5 @@ public function sweetalertConfirmed(array $payload)
}
```
> **promise** : the resolved promise from **sweetalert**.
> **envelope** : the notification where the event happened.
- **promise**: The resolved promise from **SweetAlert**.
- **envelope**: The notification where the event happened.
+60 -45
View File
@@ -1,15 +1,15 @@
---
permalink: /symfony/
title: Symfony
description: Integrate PHPFlasher in your Symfony application to enhance user experience with flash notifications. This open-source package simplifies the addition of engaging messages following user actions.
description: Integrate PHPFlasher into your Symfony application to enhance user experience with flash notifications. This guide shows you how to add engaging messages after user actions using PHPFlasher in Symfony.
framework: symfony
---
## <i class="fa-duotone fa-list-radio"></i> Requirements
<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> offers a seamless way to incorporate flash notifications in <i class="fa-brands fa-symfony text-black fa-xl"></i> <strong>Symfony</strong> projects, enhancing user feedback with minimal setup.
**<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>** helps you easily add flash notifications to your **<i class="fa-brands fa-symfony text-black fa-xl"></i> Symfony** projects, improving user feedback with minimal setup.
Requirements for using <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> with Symfony:
To use **<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>** with Symfony, you need:
> <i class="fa-brands fa-php fa-2xl text-blue-900 mr-1 mb-1"></i> **PHP** v8.2 or higher
> <i class="fa-brands fa-symfony fa-2xl text-black mr-1 ml-4"></i> **Symfony** v7.0 or higher
@@ -18,13 +18,15 @@ Requirements for using <strong><span class="text-indigo-900">PHP<span class="tex
## <i class="fa-duotone fa-list-radio"></i> Installation
<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>'s modular design lets you select and install only the components your project needs.
**<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>** is modular. You can install only the parts you need.
Run this command to install it:
```shell
composer require php-flasher/flasher-symfony
```
After installation, you need to run another command to set up the necessary assets for <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>:
After installing, run this command to set up the required assets:
```shell
php bin/console flasher:install
@@ -38,62 +40,77 @@ php bin/console flasher:install
## <i class="fa-duotone fa-list-radio"></i> Configuration
As optional, if you want to modify the default configuration, you can publish the configuration file:
If you want to change the default settings, you can publish the configuration file:
```bash
php bin/console flasher:install --config
```
The configuration file will be located at `config/packages/flasher.yaml` and will have the following content:
This will create a file at `config/packages/flasher.yaml` with the following content:
```yaml
# config/packages/flasher.yaml
flasher:
# Default notification library (e.g., 'flasher', 'toastr', 'noty', etc.)
# Default notification library (e.g., 'flasher', 'toastr', 'noty', 'notyf', 'sweetalert')
default: flasher
# Path to the main JavaScript file of PHPFlasher
# Path to the main PHPFlasher JavaScript file
main_script: '/vendor/flasher/flasher.min.js'
# Path to the stylesheets for PHPFlasher notifications
# List of CSS files to style your notifications
styles:
- '/vendor/flasher/flasher.min.css'
# Enable translation of PHPFlasher messages using Symfony's translator service
translate: true
# Automatically inject PHPFlasher assets in HTML response
# Set global options for all notifications (optional)
# options:
# # Time in milliseconds before the notification disappears
# timeout: 5000
# # Where the notification appears on the screen
# position: 'top-right'
# Automatically inject JavaScript and CSS assets into your HTML pages
inject_assets: true
# Global options
options:
# timeout in milliseconds
timeout: 5000
position: 'top-right'
# Enable message translation using Symfony's translation service
translate: true
# Map Symfony session keys to PHPFlasher notification types
# URL patterns to exclude from asset injection and flash_bag conversion
excluded_paths:
- '/^\/_profiler/'
- '/^\/_fragment/'
# Map Symfony flash message keys to notification types
flash_bag:
success: ['success']
error: ['error', 'danger']
warning: ['warning', 'alarm']
info: ['info', 'notice', 'alert']
success: ['success']
error: ['error', 'danger']
warning: ['warning', 'alarm']
info: ['info', 'notice', 'alert']
# Set criteria to filter which notifications are displayed (optional)
# filter:
# # Maximum number of notifications to show at once
# limit: 5
# Define notification presets to simplify notification creation (optional)
# presets:
# # Example preset:
# entity_saved:
# type: 'success'
# title: 'Entity saved'
# message: 'Entity saved successfully'
# Criteria to filter displayed notifications (limit, types)
filter:
# Limit number of displayed notifications
limit: 5
```
---
## <i class="fa-duotone fa-list-radio"></i> Presets
You can create a preset for a custom notification that you want to reuse in multiple places by adding a presets entry in the configuration file.
You can create a preset for a custom notification that you want to reuse in multiple places. Add a `presets` entry in the configuration file.
> You can think of a preset as a pre-defined message that you can use in multiple locations. <br>
> A preset is like a pre-defined message you can use in many places.
For example, you can create a preset named `entity_saved` in the configuration file and then use
For example, create a preset named `entity_saved`:
{% assign id = '#/ symfony preset' %}
{% assign type = 'success' %}
@@ -113,7 +130,7 @@ flasher:
title: '{{ title }}'
```
To use the preset, you can call the `preset()` method and pass the name of the preset as the first argument:
To use the preset, call the `preset()` method and pass the name of the preset:
```php
{{ id }}
@@ -125,7 +142,7 @@ class BookController
flash()->preset('entity_saved');
```
This is equivalent to:
This is the same as:
```php
class BookController
@@ -137,7 +154,7 @@ class BookController
<p id="preset-variables"><a href="#preset-variables" class="anchor"><i class="fa-duotone fa-link"></i> Variables</a></p>
Presets can also contain variables that can be substituted by using the translation system. Take the following example where you have a preset showing a personalised welcome message to the user.
Presets can also have variables that you can replace using the translation system. For example, you can have a preset that shows a personalized welcome message.
```yaml
# config/packages/flasher.yaml
@@ -149,7 +166,7 @@ flasher:
message: welcome_back_user
```
In the translations file you can define `welcome_back_user` with the message containing the variable `:username`.
In your translation file, define `welcome_back_user` with a message containing the variable `:username`.
```yaml
# translations/flasher.en.yaml
@@ -157,7 +174,7 @@ In the translations file you can define `welcome_back_user` with the message con
welcome_back_user: Welcome back :username
```
If you want to substitute the `:username` in the above translation with a username in the controller, you can achieve this by passing an array of values to be substituted as the second argument.
To replace `:username` with the actual username in your controller, pass an array with the values to substitute as the second argument:
```php
class BookController
@@ -175,10 +192,9 @@ class BookController
## <i class="fa-duotone fa-list-radio"></i> RTL support
<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> makes it easy to incorporate <i class="fa-duotone fa-signs-post text-indigo-900 mr-1 fa-lg"></i> **right-to-left** languages like `Arabic` or `Hebrew`.
it automatically detects the text direction and handles the necessary adjustments for you.
**<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>** makes it easy to use <i class="fa-duotone fa-signs-post text-indigo-900 mr-1 fa-lg"></i> **right-to-left** languages like `Arabic` or `Hebrew`. It automatically detects the text direction and adjusts accordingly.
Simply make sure the translation service is enabled and let <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> handle the rest.
Just make sure the translation service is enabled, and **<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>** will handle the rest.
{% assign id = '#/ phpflasher rtl' %}
{% assign type = 'success' %}
@@ -199,14 +215,13 @@ flash()
## <i class="fa-duotone fa-list-radio"></i> Translation
<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong> allows you to translate your notification `messages` and `presets`, it comes with `Arabic`, `English`, `French`, `German`, `Spanish`, `Portuguese`, `Russian`, and `Chinese` translations out of the box. but you can easily add your own translations.
**<strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>** lets you translate your notification `messages` and `presets`. It comes with translations for `Arabic`, `English`, `French`, `German`, `Spanish`, `Portuguese`, `Russian`, and `Chinese`. You can also add your own translations.
For example, to override the `English` translation strings for <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>, you can create a language file at the following location:
**`translations/flasher.en.yaml`**.
To override the `English` translations for <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>, create a file at `translations/flasher.en.yaml`.
In this file, you should **only** define the translation strings you want to override. Any translation strings that you don't override will still be loaded from <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>'s original language files.
In this file, define **only** the translation strings you want to change. Any strings you don't override will use <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>'s default translations.
Here are examples of the default translation keys for `Arabic`, `English`, and `French` in <strong><span class="text-indigo-900">PHP<span class="text-indigo-500">Flasher</span></span></strong>:
Here are examples of the default translation keys for `Arabic`, `English`, and `French`:
```yaml
# translations/flasher.ar.yaml
@@ -256,7 +271,7 @@ The resource was deleted: 'La ressource :resource a été supprimée'
resource: ''
```
> These translation files facilitate localizing notifications to match user preferences and ensure that your applications can communicate effectively across different linguistic contexts.
> These translation files help you localize notifications to match user preferences, so your application can communicate effectively in different languages.
{% assign id = '#/ symfony arabic translations' %}
{% assign successMessage = 'تم إنشاء الملف' %}
+31
View File
@@ -0,0 +1,31 @@
# Support Palestine
# Donate via trusted institutions
**Donate via trusted institutions**
The best way to financially support Palestine is by donating directly to one of the trusted institutions in your country.
**Donate to associations acting in Palestine**
- [Doctors without borders](https://donate.doctorswithoutborders.org/secure/rr-donate-monthly-web?source=ADU2011U0W46) : Provides medical help to palestinians.
- [WFP - World Food Programme](https://donate.wfp.org/1244/donation/single/?campaign=3493) : Provides food to palestinians.
- [Palestine red crescent society](https://www.palestinercs.org/en/Donation) : Provides medical help to palestinians.
- [UNRWA - United Nations Relief and Works](https://donate.unrwa.org/-landing-page/en_EN) : Provides food and cash assistance to palestinians.
- [Save the children](https://donate.savethechildren.org/en) : Provides protection for children.
- [Alkhidmat](https://alkhidmat.org/donate) : Provides food and medical help to palestinians.
**Other way to support**
- 🗣 Dont be silent:
- Add banners to your open source project and profile.
- Protest against the war in your city.
- Demand severe sanctions against Israel and support for Palestine from your leaders.
- Reach out to Palestinian friends, offer help.
- ❌ Boycott Israeli businesses:
- Cancel subscriptions and stop giving your money to Israeli software, dependencies and infrastructure companies.
- Cancel subscriptions and stop giving your money to companies which support israel.
- Suffocate Israeli economy to limit its ability to fund the war!
- 📰 Resist propaganda:
- Educate yourself and others on the Israeli threat.
- Check out common misbeliefs.
+1 -2
View File
@@ -1,7 +1,6 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
'./_site/**/*.html',
'./_site/**/*.js',
'./_site/**/*.{html,js}',
],
}
+2
View File
@@ -8,4 +8,6 @@ return static function (MBConfig $config) {
$config->packageDirectories([
__DIR__.'/src',
]);
// $config->packageAliasFormat('2.x-dev');
};
+3672 -3412
View File
File diff suppressed because it is too large Load Diff
+19 -19
View File
@@ -1,7 +1,7 @@
{
"name": "@flasher/php-flasher",
"type": "module",
"version": "2.0.0",
"version": "2.1.5",
"license": "MIT",
"workspaces": [
"src/Prime/Resources",
@@ -18,42 +18,42 @@
"ncu": "ncu -u && npm run ncu --workspaces"
},
"devDependencies": {
"@antfu/eslint-config": "2.12.2",
"@babel/core": "^7.25.2",
"@babel/preset-env": "^7.25.4",
"@antfu/eslint-config": "^2.27.3",
"@babel/core": "^7.26.9",
"@babel/preset-env": "^7.26.9",
"@rollup/plugin-babel": "^6.0.4",
"@rollup/plugin-commonjs": "^25.0.8",
"@rollup/plugin-eslint": "^9.0.5",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-node-resolve": "^15.3.1",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@types/node": "^20.16.5",
"@typescript-eslint/eslint-plugin": "7.5.0",
"@types/node": "^20.17.19",
"@typescript-eslint/eslint-plugin": "^7.18.0",
"@typescript-eslint/parser": "^7.18.0",
"all-contributors-cli": "^6.26.1",
"autoprefixer": "^10.4.20",
"browserslist": "^4.23.3",
"cross-env": "7.0.3",
"browserslist": "^4.24.4",
"cross-env": "^7.0.3",
"cssnano": "^6.1.2",
"eslint": "^8.57.1",
"eslint-config-airbnb-typescript": "^18.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.3",
"eslint-plugin-babel": "5.3.1",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-import-resolver-typescript": "^3.8.3",
"eslint-plugin-babel": "^5.3.1",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.2.3",
"postcss-discard-comments": "^6.0.2",
"punycode": "2.3.1",
"rollup": "^4.22.0",
"punycode": "^2.3.1",
"rollup": "^4.34.8",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-clear": "^2.0.7",
"rollup-plugin-copy": "3.5.0",
"rollup-plugin-copy": "^3.5.0",
"rollup-plugin-filesize": "^10.0.0",
"rollup-plugin-postcss": "^4.0.2",
"rollup-plugin-progress": "^1.1.2",
"sass": "^1.79.1",
"sass": "^1.85.0",
"ts-node": "^10.9.2",
"tslib": "^2.7.0",
"typescript": "^5.6.2"
"tslib": "^2.8.1",
"typescript": "^5.7.3"
}
}
+3
View File
@@ -8,6 +8,9 @@ includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
rules:
- Spatie\Ray\PHPStan\RemainingRayCallRule
parameters:
level: 9
+7 -14
View File
@@ -2,13 +2,7 @@
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\AddSeeTestAnnotationRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\SetList;
return RectorConfig::configure()
return Rector\Config\RectorConfig::configure()
->withPaths([
__DIR__.'/src/',
__DIR__.'/tests/',
@@ -16,12 +10,11 @@ return RectorConfig::configure()
])
->withRootFiles()
->withSets([
SetList::PHP_82,
PHPUnitSetList::PHPUNIT_100,
PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
Rector\Set\ValueObject\SetList::PHP_82,
Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_110,
Rector\PHPUnit\Set\PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES,
Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_CODE_QUALITY,
])
->withSkip([
AddSeeTestAnnotationRector::class,
StringClassNameToClassConstantRector::class,
->withRules([
Spatie\Ray\Rector\RemoveRayCallRector::class,
]);
+8
View File
@@ -0,0 +1,8 @@
Please do not submit any Pull Requests here. They will be closed.
---
Please submit your PR here instead:
https://github.com/php-flasher/php-flasher
This repository is what we call a "subtree split": a read-only subset of that main repository.
We're looking forward to your PR there!
+20
View File
@@ -0,0 +1,20 @@
name: Close Pull Request
on:
pull_request_target:
types: [opened]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: |
Thanks for your Pull Request! We love contributions.
However, you should instead open your PR on the main repository:
https://github.com/php-flasher/php-flasher
This repository is what we call a "subtree split": a read-only subset of that main repository.
We're looking forward to your PR there!
+22 -19
View File
@@ -35,9 +35,9 @@ use Flasher\Prime\Storage\Storage;
use Flasher\Prime\Storage\StorageManager;
use Illuminate\Container\Container;
use Illuminate\Contracts\Events\Dispatcher;
use Illuminate\Contracts\Http\Kernel as HttpKernel;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Console\AboutCommand;
use Illuminate\Foundation\Http\Kernel as HttpKernel;
use Illuminate\View\Compilers\BladeCompiler;
use Laravel\Octane\Events\RequestReceived;
use Livewire\LivewireManager;
@@ -227,32 +227,18 @@ final class FlasherServiceProvider extends PluginServiceProvider
}
$this->app->singleton(FlasherMiddleware::class, static function (Application $app) {
$config = $app->make('config');
$flasher = $app->make('flasher');
$cspHandler = $app->make('flasher.csp_handler');
$excludedPaths = $config->get('flasher.excluded_paths', []) ?: [];
return new FlasherMiddleware(new ResponseExtension($flasher, $cspHandler));
return new FlasherMiddleware(new ResponseExtension($flasher, $cspHandler, $excludedPaths));
});
$this->pushMiddlewareToGroup(FlasherMiddleware::class);
}
private function registerCspHandler(): void
{
$this->app->singleton('flasher.csp_handler', static function () {
return new ContentSecurityPolicyHandler(new NonceGenerator());
});
}
private function registerAssetManager(): void
{
$this->app->singleton('flasher.asset_manager', static function () {
$publicDir = public_path('/');
$manifestPath = public_path('vendor'.\DIRECTORY_SEPARATOR.'flasher'.\DIRECTORY_SEPARATOR.'manifest.json');
return new AssetManager($publicDir, $manifestPath);
});
}
private function registerSessionMiddleware(): void
{
if (!$this->getConfig('flash_bag')) {
@@ -278,6 +264,23 @@ final class FlasherServiceProvider extends PluginServiceProvider
});
}
private function registerCspHandler(): void
{
$this->app->singleton('flasher.csp_handler', static function () {
return new ContentSecurityPolicyHandler(new NonceGenerator());
});
}
private function registerAssetManager(): void
{
$this->app->singleton('flasher.asset_manager', static function () {
$publicDir = public_path('/');
$manifestPath = public_path('vendor'.\DIRECTORY_SEPARATOR.'flasher'.\DIRECTORY_SEPARATOR.'manifest.json');
return new AssetManager($publicDir, $manifestPath);
});
}
private function registerBladeDirectives(BladeCompiler $blade): void
{
$blade->directive('flasher_render', function (string $expression = '') {
+5
View File
@@ -14,6 +14,11 @@ final readonly class Request implements RequestInterface
{
}
public function getUri(): string
{
return $this->request->getUri();
}
public function isXmlHttpRequest(): bool
{
return $this->request->ajax();
+3 -1
View File
@@ -13,6 +13,7 @@ namespace Illuminate\Contracts\Config;
* scripts: string[],
* styles: string[],
* options: array<string, mixed>,
* excluded_paths?: list<non-empty-string>,
* filter: array<string, mixed>,
* flash_bag: array<string, string[]>,
* presets: array<string, PresetType>,
@@ -44,7 +45,8 @@ interface Repository
* ($key is 'flasher.presets' ? array<string, PresetType> :
* ($key is 'flasher.plugins' ? array<string, PluginType> :
* ($key is 'flasher.flash_bag' ? array<string, string[]> :
* mixed)))))))
* ($key is 'flasher.excluded_paths' ? list<non-empty-string> :
* mixed))))))))
*/
public function get(string|array $key, mixed $default = null): mixed;
}
+323 -52
View File
@@ -1,106 +1,375 @@
<div align="center">
<a href="https://github.com/php-flasher/php-flasher/blob/2.x/docs/palestine.md">
<img src="https://raw.githubusercontent.com/php-flasher/art/main/palestine-banner-support.svg" width="800px" alt="Help Palestine"/>
</a>
</div>
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/php-flasher/art/main/php-flasher-github-dark.png">
<img src="https://raw.githubusercontent.com/php-flasher/art/main/php-flasher-github.png" alt="PHPFlasher Logo">
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/php-flasher/art/main/php-flasher-logo-dark.png">
<img src="https://raw.githubusercontent.com/php-flasher/art/main/php-flasher-logo.png" alt="PHPFlasher Logo">
</picture>
</p>
# PHPFlasher for Laravel
<p align="center">
<a href="https://www.linkedin.com/in/younes--ennaji"><img src="https://img.shields.io/badge/author-@yoeunes-blue.svg" alt="Author Badge"></a>
<a href="https://github.com/php-flasher/php-flasher"><img src="https://img.shields.io/badge/source-php--flasher/php--flasher-blue.svg" alt="Source Code Badge"></a>
<a href="https://github.com/php-flasher/php-flasher/releases"><img src="https://img.shields.io/github/tag/php-flasher/flasher.svg" alt="GitHub Release Badge"></a>
<a href="https://github.com/php-flasher/flasher/blob/master/LICENSE"><img src="https://img.shields.io/badge/license-MIT-brightgreen.svg" alt="License Badge"></a>
<a href="https://packagist.org/packages/php-flasher/flasher"><img src="https://img.shields.io/packagist/dt/php-flasher/flasher.svg" alt="Packagist Downloads Badge"></a>
<a href="https://github.com/php-flasher/php-flasher"><img src="https://img.shields.io/github/stars/php-flasher/php-flasher.svg" alt="GitHub Stars Badge"></a>
<a href="https://packagist.org/packages/php-flasher/flasher"><img src="https://img.shields.io/packagist/php-v/php-flasher/flasher.svg" alt="Supported PHP Version Badge"></a>
</p>
PHPFlasher provides a powerful and intuitive way to add flash notifications to your Laravel applications. With PHPFlasher, you can enhance user feedback efficiently and elegantly.
## Table of Contents
## Official Documentation
- [About PHPFlasher Laravel Adapter](#about-phpflasher-laravel-adapter)
- [Features](#features)
- [Supported Versions](#supported-versions)
- [Installation](#installation)
- [Core Package](#core-package)
- [Adapters](#adapters)
- [Configuration](#configuration)
- [Configuration File](#configuration-file)
- [Configuration Options](#configuration-options)
- [Quick Start](#quick-start)
- [Usage Examples](#usage-examples)
- [Adapters Overview](#adapters-overview)
- [Official Documentation](#official-documentation)
- [Contributors and Sponsors](#contributors-and-sponsors)
- [Contact](#contact)
- [License](#license)
For more comprehensive documentation, please visit [PHPFlasher's Official Documentation](https://php-flasher.io).
## About PHPFlasher Laravel Adapter
## Requirements
**PHPFlasher Laravel Adapter** is an open-source package that seamlessly integrates PHPFlasher's powerful flash messaging capabilities into your **Laravel** applications. It simplifies the process of adding flash messages, providing an intuitive API to enhance user experience with minimal setup.
- **PHP** v8.2 or higher
- **Laravel** v11.0 or higher
With PHPFlasher Laravel Adapter, you can effortlessly display success, error, warning, and informational messages to your users, ensuring clear communication of application states and actions.
## Features
- **Seamless Laravel Integration**: Designed specifically for Laravel, ensuring compatibility and ease of use.
- **Multiple Notification Libraries**: Supports various frontend libraries like Toastr, Noty, SweetAlert, and Notyf.
- **Flexible Configuration**: Customize the appearance and behavior of flash messages to fit your application's needs.
- **Intuitive API**: Simple methods to create and manage flash messages without boilerplate code.
- **Extensible**: Easily add or create new adapters for different frontend libraries.
## Supported Versions
| PHPFlasher Laravel Adapter Version | PHP Version | Laravel Version |
|------------------------------------|-------------|-----------------|
| **v2.x** | ≥ 8.2 | ≥ 11 |
| **v1.x** | ≥ 5.3 | ≥ 4.0 |
> **Note:** Ensure your project meets the PHP and Laravel version requirements for the PHPFlasher Laravel Adapter version you intend to use. For older PHP or Laravel versions, refer to [PHPFlasher v1.x](https://github.com/php-flasher/flasher-laravel/tree/1.x).
## Installation
To install PHPFlasher for Laravel, use Composer:
### Core Package
Install the PHPFlasher Laravel Adapter via Composer:
```bash
composer require php-flasher/flasher-laravel
```
After installation, publish the assets using:
After installation, set up the necessary assets:
```bash
```shell
php artisan flasher:install
```
## Usage
> **Note:** PHPFlasher automatically injects the necessary JavaScript and CSS assets into your Blade templates. No additional steps are required for asset injection.
Quickly integrate flash notifications in your Laravel project using the simple methods provided by PHPFlasher.
### Adapters
- Display a success message.
PHPFlasher provides various adapters for different notification libraries. Below is an overview of available adapters for Laravel:
```php
flash()->success('Operation completed successfully.');
- [flasher-toastr-laravel](https://github.com/php-flasher/flasher-toastr-laravel) - Laravel Adapter
- [flasher-noty-laravel](https://github.com/php-flasher/flasher-noty-laravel) - Laravel Adapter
- [flasher-notyf-laravel](https://github.com/php-flasher/flasher-notyf-laravel) - Laravel Adapter
- [flasher-sweetalert-laravel](https://github.com/php-flasher/flasher-sweetalert-laravel) - Laravel Adapter
For detailed installation and usage instructions for each adapter, refer to their respective `README.md`.
## Configuration
After installing the PHPFlasher Laravel Adapter, you can configure it by publishing the configuration file or by modifying it directly.
### Configuration File
If you need to customize the default settings, publish the configuration file using the following command:
```bash
php artisan flasher:install --config
```
- Display an error message.
This will create a file at `config/flasher.php` with the following content:
```php
flash()->error('Oops, something went wrong.');
<?php
declare(strict_types=1);
use Flasher\Prime\Configuration;
return Configuration::from([
// Default notification library (e.g., 'flasher', 'toastr', 'noty', 'notyf', 'sweetalert')
'default' => 'flasher',
// Path to the main PHPFlasher JavaScript file
'main_script' => '/vendor/flasher/flasher.min.js',
// List of CSS files to style your notifications
'styles' => [
'/vendor/flasher/flasher.min.css',
],
// Set global options for all notifications (optional)
// 'options' => [
// 'timeout' => 5000, // Time in milliseconds before the notification disappears
// 'position' => 'top-right', // Where the notification appears on the screen
// ],
// Automatically inject JavaScript and CSS assets into your HTML pages
'inject_assets' => true,
// Enable message translation using Laravel's translation service
'translate' => true,
// URL patterns to exclude from asset injection and flash_bag conversion
'excluded_paths' => [],
// Map Laravel flash message keys to notification types
'flash_bag' => [
'success' => ['success'],
'error' => ['error', 'danger'],
'warning' => ['warning', 'alarm'],
'info' => ['info', 'notice', 'alert'],
],
// Set criteria to filter which notifications are displayed (optional)
// 'filter' => [
// 'limit' => 5, // Maximum number of notifications to show at once
// ],
// Define notification presets to simplify notification creation (optional)
// 'presets' => [
// 'entity_saved' => [
// 'type' => 'success',
// 'title' => 'Entity saved',
// 'message' => 'Entity saved successfully',
// ],
// ],
]);
```
- Display a warning message.
### Configuration Options
| **Option** | **Description** |
|------------------|---------------------------------------------------------------------------------------------------------------------------|
| `default` | **String**: The default notification library to use (e.g., `'flasher'`, `'toastr'`, `'noty'`, `'notyf'`, `'sweetalert'`). |
| `main_script` | **String**: Path to the main PHPFlasher JavaScript file. |
| `styles` | **Array**: List of CSS files to style your notifications. |
| `options` | **Array** (Optional): Global options for all notifications (e.g., `'timeout'`, `'position'`). |
| `inject_assets` | **Boolean**: Whether to automatically inject JavaScript and CSS assets into your HTML pages. |
| `translate` | **Boolean**: Enable message translation using Laravels translation service. |
| `excluded_paths` | **Array**: URL patterns to exclude from asset injection and flash_bag conversion. |
| `flash_bag` | **Array**: Map Laravel flash message keys to notification types. |
| `filter` | **Array** (Optional): Criteria to filter which notifications are displayed (e.g., `'limit'`). |
| `presets` | **Array** (Optional): Define notification presets to simplify notification creation. |
## Quick Start
To display a notification message, you can either use the `flash()` helper function or obtain an instance of `flasher` from the service container. Then, before returning a view or redirecting, call the desired method (`success()`, `error()`, etc.) and pass in the message to be displayed.
### Using the `flash()` Helper
```php
flash()->warning('Your account may have been compromised.');
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class BookController extends Controller
{
public function saveBook()
{
// Your logic here
flash('Your changes have been saved!');
return redirect()->back();
}
}
```
- Display an informational message.
### Using the `flasher` Service
```php
flash()->info('This may take some time. Do not refresh the page.');
<?php
namespace App\Http\Controllers;
use Flasher\Prime\FlasherInterface;
class AnotherController extends Controller
{
/**
* If you prefer to use dependency injection
*/
public function register(FlasherInterface $flasher)
{
// Your logic here
$flasher->success('Your changes have been saved!');
// ... redirect or render the view
}
public function update()
{
// Your logic here
app('flasher')->error('An error occurred while updating.');
return redirect()->back();
}
}
```
- Set multiple options at once.
## Usage Examples
### Success Message
```php
flash()
->options(['timeout' => 5000, 'position' => 'top-right'])
->success('Your profile has been updated.');
flash()->success('Operation completed successfully!');
```
- Set a single option.
### Error Message
```php
flash()
->option('timer', 5000)
->success('Your reservation has been confirmed.');
flash()->error('An error occurred.');
```
- Set the priority of the message.
### Info Message
```php
flash()
->priority(1)
->success('Your subscription has been activated.');
flash()->info('This is an informational message.');
```
- Set how many requests a message should persist through.
### Warning Message
```php
flash()
->hops(2)
->info('Your account has been created, but requires verification.');
flash()->warning('This is a warning message.');
```
- Translate a message into the specified language.
### Passing Options
```php
flash()
->translate('ar')
->success('Your message has been sent.');
flash()->success('Custom message with options.', ['timeout' => 3000, 'position' => 'bottom-left']);
```
## Contributors
### Using presets
Define a preset in your `config/flasher.php`:
```php
<?php
declare(strict_types=1);
use Flasher\Prime\Configuration;
return Configuration::from([
// ... other configurations
'presets' => [
'entity_saved' => [
'type' => 'success',
'title' => 'Entity Saved',
'message' => 'The entity has been saved successfully.',
],
'entity_deleted' => [
'type' => 'warning',
'title' => 'Entity Deleted',
'message' => 'The entity has been deleted.',
],
],
]);
```
Use the preset in your controller:
```php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\RedirectResponse;
use App\Http\Controllers\Controller;
class BookController extends Controller
{
/**
* Save a new book entity.
*
* @return RedirectResponse
*/
public function saveBook(): RedirectResponse
{
// Your saving logic here (e.g., validating and storing the book)
// Trigger the 'entity_saved' preset
flash()->preset('entity_saved');
return redirect()->route('books.index');
}
/**
* Delete an existing book entity.
*
* @return RedirectResponse
*/
public function deleteBook(): RedirectResponse
{
// Your deletion logic here (e.g., finding and deleting the book)
// Trigger the 'entity_deleted' preset
flash()->preset('entity_deleted');
return redirect()->route('books.index');
}
}
```
## Adapters Overview
PHPFlasher supports various adapters to integrate seamlessly with different frontend libraries. Below is an overview of available adapters for Laravel:
| Adapter Repository | Description |
|-----------------------------------------------------------------------------------------|--------------------------------|
| [flasher-laravel](https://github.com/php-flasher/flasher-laravel) | Laravel framework adapter |
| [flasher-toastr-laravel](https://github.com/php-flasher/flasher-toastr-laravel) | Toastr adapter for Laravel |
| [flasher-noty-laravel](https://github.com/php-flasher/flasher-noty-laravel) | Noty adapter for Laravel |
| [flasher-notyf-laravel](https://github.com/php-flasher/flasher-notyf-laravel) | Notyf adapter for Laravel |
| [flasher-sweetalert-laravel](https://github.com/php-flasher/flasher-sweetalert-laravel) | SweetAlert adapter for Laravel |
> **Note:** Each adapter has its own repository. For detailed installation and usage instructions, please refer to the [Official Documentation](https://php-flasher.io).
## Official Documentation
Comprehensive documentation for PHPFlasher is available at [https://php-flasher.io](https://php-flasher.io). Here you will find detailed guides, API references, and advanced usage examples to help you get the most out of PHPFlasher.
## Contributors and sponsors
Join our team of contributors and make a lasting impact on our project!
We are always looking for passionate individuals who want to contribute their skills and ideas.
Whether you're a developer, designer, or simply have a great idea, we welcome your participation and collaboration.
Shining stars of our community:
<!-- ALL-CONTRIBUTORS-LIST:START -->
<!-- prettier-ignore-start -->
@@ -108,7 +377,7 @@ flash()
<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/younes-ennaji/"><img src="https://avatars.githubusercontent.com/u/10859693?v=4?s=100" width="100px;" alt="Younes ENNAJI"/><br /><sub><b>Younes ENNAJI</b></sub></a><br /><a href="https://github.com/php-flasher/php-flasher/commits?author=yoeunes" title="Code">💻</a> <a href="https://github.com/php-flasher/php-flasher/commits?author=yoeunes" title="Documentation">📖</a> <a href="#maintenance-yoeunes" title="Maintenance">🚧</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://www.linkedin.com/in/younes--ennaji/"><img src="https://avatars.githubusercontent.com/u/10859693?v=4?s=100" width="100px;" alt="Younes ENNAJI"/><br /><sub><b>Younes ENNAJI</b></sub></a><br /><a href="https://github.com/php-flasher/php-flasher/commits?author=yoeunes" title="Code">💻</a> <a href="https://github.com/php-flasher/php-flasher/commits?author=yoeunes" title="Documentation">📖</a> <a href="#maintenance-yoeunes" title="Maintenance">🚧</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/salmayno"><img src="https://avatars.githubusercontent.com/u/27933199?v=4?s=100" width="100px;" alt="Salma Mourad"/><br /><sub><b>Salma Mourad</b></sub></a><br /><a href="#financial-salmayno" title="Financial">💵</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://www.youtube.com/rstacode"><img src="https://avatars.githubusercontent.com/u/35005761?v=4?s=100" width="100px;" alt="Nashwan Abdullah"/><br /><sub><b>Nashwan Abdullah</b></sub></a><br /><a href="#financial-codenashwan" title="Financial">💵</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://darvis.nl/"><img src="https://avatars.githubusercontent.com/u/7394837?v=4?s=100" width="100px;" alt="Arvid de Jong"/><br /><sub><b>Arvid de Jong</b></sub></a><br /><a href="#financial-darviscommerce" title="Financial">💵</a></td>
@@ -118,7 +387,7 @@ flash()
</tr>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://www.instagram.com/lucas.maciel_z"><img src="https://avatars.githubusercontent.com/u/80225404?v=4?s=100" width="100px;" alt="Lucas Maciel"/><br /><sub><b>Lucas Maciel</b></sub></a><br /><a href="#design-LucasStorm" title="Design">🎨</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://siek.io/"><img src="https://avatars.githubusercontent.com/u/5730766?v=4?s=100" width="100px;" alt="Antoni Siek"/><br /><sub><b>Antoni Siek</b></sub></a><br /><a href="https://github.com/php-flasher/php-flasher/commits?author=ImJustToNy" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/AhmedGamal"><img src="https://avatars.githubusercontent.com/u/11786167?v=4?s=100" width="100px;" alt="Ahmed Gamal"/><br /><sub><b>Ahmed Gamal</b></sub></a><br /><a href="https://github.com/php-flasher/php-flasher/commits?author=AhmedGamal" title="Code">💻</a> <a href="https://github.com/php-flasher/php-flasher/commits?author=AhmedGamal" title="Documentation">📖</a></td>
</tr>
</tbody>
</table>
@@ -130,15 +399,17 @@ flash()
## Contact
For support, feature requests, or contributions, reach out via:
PHPFlasher is being actively developed by <a href="https://github.com/yoeunes">yoeunes</a>.
You can reach out with questions, bug reports, or feature requests on any of the following:
- [GitHub Issues](https://github.com/php-flasher/php-flasher/issues)
- [Github Issues](https://github.com/php-flasher/php-flasher/issues)
- [Github](https://github.com/yoeunes)
- [Twitter](https://twitter.com/yoeunes)
- [LinkedIn](https://www.linkedin.com/in/younes--ennaji//)
- [Email](mailto:younes.ennaji.pro@gmail.com)
- [Linkedin](https://www.linkedin.com/in/younes--ennaji/)
- [Email me directly](mailto:younes.ennaji.pro@gmail.com)
## License
PHPFlasher is licensed under the [MIT license](https://opensource.org/licenses/MIT).
PHPFlasher is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
<p align="center"> <b>Made with ❤️ by <a href="https://www.linkedin.com/in/younes--ennaji//">Younes ENNAJI</a> </b> </p>
<p align="center"> <b>Made with ❤️ by <a href="https://www.linkedin.com/in/younes--ennaji/">Younes ENNAJI</a> </b> </p>
+31 -20
View File
@@ -2,34 +2,36 @@
declare(strict_types=1);
namespace Flasher\Laravel\Resources;
use Flasher\Prime\Configuration;
return [
// Default notification library (e.g., 'flasher', 'toastr', 'noty', etc.)
return Configuration::from([
// Default notification library (e.g., 'flasher', 'toastr', 'noty', 'notyf', 'sweetalert')
'default' => 'flasher',
// Path to the main JavaScript file of PHPFlasher
// Path to the main PHPFlasher JavaScript file
'main_script' => '/vendor/flasher/flasher.min.js',
// Path to the stylesheets for PHPFlasher notifications
// List of CSS files to style your notifications
'styles' => [
'/vendor/flasher/flasher.min.css',
],
// Whether to translate PHPFlasher messages using Laravel's translation service
'translate' => true,
// Set global options for all notifications (optional)
// 'options' => [
// 'timeout' => 5000, // Time in milliseconds before the notification disappears
// 'position' => 'top-right', // Where the notification appears on the screen
// ],
// Automatically inject PHPFlasher assets into HTML response
// Automatically inject JavaScript and CSS assets into your HTML pages
'inject_assets' => true,
// Global options
'options' => [
'timeout' => 5000, // in milliseconds
'position' => 'top-right',
],
// Enable message translation using Laravel's translation service
'translate' => true,
// Configuration for the flash bag (converting Laravel flash messages)
// Map Laravel session keys to PHPFlasher types
// URL patterns to exclude from asset injection and flash_bag conversion
'excluded_paths' => [],
// Map Laravel flash message keys to notification types
'flash_bag' => [
'success' => ['success'],
'error' => ['error', 'danger'],
@@ -37,8 +39,17 @@ return [
'info' => ['info', 'notice', 'alert'],
],
// Filter criteria for notifications (e.g., limit number, types)
'filter' => [
'limit' => 5, // Limit the number of displayed notifications
],
];
// Set criteria to filter which notifications are displayed (optional)
// 'filter' => [
// 'limit' => 5, // Maximum number of notifications to show at once
// ],
// Define notification presets to simplify notification creation (optional)
// 'presets' => [
// 'entity_saved' => [
// 'type' => 'success',
// 'title' => 'Entity saved',
// 'message' => 'Entity saved successfully',
// ],
// ],
]);
+2 -2
View File
@@ -28,8 +28,8 @@
"prefer-stable": true,
"require": {
"php": ">=8.2",
"illuminate/support": "^11.0",
"php-flasher/flasher": "^2.0.1"
"illuminate/support": "^11.0|^12.0",
"php-flasher/flasher": "^2.1.5"
},
"autoload": {
"psr-4": {
+8
View File
@@ -0,0 +1,8 @@
Please do not submit any Pull Requests here. They will be closed.
---
Please submit your PR here instead:
https://github.com/php-flasher/php-flasher
This repository is what we call a "subtree split": a read-only subset of that main repository.
We're looking forward to your PR there!
@@ -0,0 +1,20 @@
name: Close Pull Request
on:
pull_request_target:
types: [opened]
jobs:
run:
runs-on: ubuntu-latest
steps:
- uses: superbrothers/close-pull-request@v3
with:
comment: |
Thanks for your Pull Request! We love contributions.
However, you should instead open your PR on the main repository:
https://github.com/php-flasher/php-flasher
This repository is what we call a "subtree split": a read-only subset of that main repository.
We're looking forward to your PR there!
+6
View File
@@ -1,3 +1,9 @@
<div align="center">
<a href="https://github.com/php-flasher/php-flasher/blob/2.x/docs/palestine.md">
<img src="https://raw.githubusercontent.com/php-flasher/art/main/palestine-banner-support.svg" width="800px" alt="Help Palestine"/>
</a>
</div>
<p align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/php-flasher/art/main/php-flasher-github-dark.png">
+2 -2
View File
@@ -28,8 +28,8 @@
"prefer-stable": true,
"require": {
"php": ">=8.2",
"php-flasher/flasher-laravel": "^2.0.1",
"php-flasher/flasher-noty": "^2.0.1"
"php-flasher/flasher-laravel": "^2.1.5",
"php-flasher/flasher-noty": "^2.1.5"
},
"autoload": {
"psr-4": {
+8
View File
@@ -0,0 +1,8 @@
Please do not submit any Pull Requests here. They will be closed.
---
Please submit your PR here instead:
https://github.com/php-flasher/php-flasher
This repository is what we call a "subtree split": a read-only subset of that main repository.
We're looking forward to your PR there!

Some files were not shown because too many files have changed in this diff Show More