Compare commits

...

51 Commits

Author SHA1 Message Date
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
149 changed files with 14787 additions and 12219 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
+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/**
-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 -1
View File
@@ -1,6 +1,25 @@
# 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.1...2.x)
## [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
+9 -3
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">
@@ -64,11 +70,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);
}
}
}
+21 -19
View File
@@ -21,27 +21,14 @@
"prefer-stable": true,
"require": {
"php": ">=8.2",
"ext-intl": "*"
},
"require-dev": {
"ext-intl": "*",
"illuminate/contracts": "^11.0",
"illuminate/routing": "^11.0",
"illuminate/support": "^11.0",
"larastan/larastan": "^2.9",
"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
+5362 -5351
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -2,6 +2,7 @@
/node_modules
/public/build
/public/hot
/public/vendor/flasher
/public/storage
/storage/*.key
/vendor
+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) {
+9 -4
View File
@@ -24,6 +24,7 @@
"spatie/laravel-ray": "^1.36"
},
"require-dev": {
"barryvdh/laravel-debugbar": "^3.14",
"fakerphp/faker": "^1.23",
"larastan/larastan": "^2.9",
"laravel/pint": "^1.13",
@@ -32,7 +33,8 @@
"nunomaduro/collision": "^8.0",
"pestphp/pest": "^2.34",
"pestphp/pest-plugin-laravel": "^2.3",
"spatie/laravel-ignition": "^2.4"
"spatie/laravel-ignition": "^2.4",
"spatie/ray": "^1.41"
},
"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",
+2169 -446
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
+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 ###
+8 -2
View File
@@ -23,6 +23,8 @@
"symfony/dotenv": "7.0.*",
"symfony/flex": "^2",
"symfony/framework-bundle": "7.0.*",
"symfony/monolog-bundle": "^3.10",
"symfony/notifier": "7.0.*",
"symfony/runtime": "7.0.*",
"symfony/translation": "7.0.*",
"symfony/twig-bundle": "7.0.*",
@@ -61,7 +63,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"
@@ -80,6 +83,9 @@
}
},
"require-dev": {
"symfony/maker-bundle": "^1.58"
"spatie/ray": "^1.41",
"symfony/maker-bundle": "^1.58",
"symfony/stopwatch": "7.0.*",
"symfony/web-profiler-bundle": "7.0.*"
}
}
+940 -16
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -11,4 +11,6 @@ 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],
];
+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
+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,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
@@ -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');
}
}
+37
View File
@@ -75,6 +75,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 +138,19 @@
"templates/base.html.twig"
]
},
"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"
}
+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.6f20ecba.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",
+31 -40
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,8 +96,7 @@ 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 = [])
@@ -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.6f20ecba.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
+463 -2417
View File
File diff suppressed because it is too large Load Diff
+4 -4
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",
@@ -17,11 +17,11 @@
"@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/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.14",
"webpack-notifier": "^1.15.0"
},
"browserslist": [
+16 -16
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,36 +33,36 @@ 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/)
@@ -73,4 +73,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');
};
+3543 -3339
View File
File diff suppressed because it is too large Load Diff
+17 -17
View File
@@ -1,7 +1,7 @@
{
"name": "@flasher/php-flasher",
"type": "module",
"version": "2.0.0",
"version": "2.1.1",
"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.25.8",
"@babel/preset-env": "^7.25.8",
"@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.0",
"@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.16.13",
"@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.0",
"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-babel": "^5.3.1",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.2.1",
"postcss-discard-comments": "^6.0.2",
"punycode": "2.3.1",
"rollup": "^4.22.0",
"punycode": "^2.3.1",
"rollup": "^4.24.0",
"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.80.3",
"ts-node": "^10.9.2",
"tslib": "^2.7.0",
"typescript": "^5.6.2"
"tslib": "^2.8.0",
"typescript": "^5.6.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,
]);
+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;
}
+7 -1
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">
@@ -108,7 +114,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>
+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',
// ],
// ],
]);
+1 -1
View File
@@ -29,7 +29,7 @@
"require": {
"php": ">=8.2",
"illuminate/support": "^11.0",
"php-flasher/flasher": "^2.0.1"
"php-flasher/flasher": "^2.1.1"
},
"autoload": {
"psr-4": {
+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.1",
"php-flasher/flasher-noty": "^2.1.1"
},
"autoload": {
"psr-4": {
+130 -13
View File
@@ -4,10 +4,110 @@ declare(strict_types=1);
namespace Flasher\Noty\Prime;
use Flasher\Prime\Notification\Envelope;
use Flasher\Prime\Notification\NotificationBuilder;
/**
* @phpstan-type NotificationType "success"|"info"|"warning"|"error"|"alert"|"information"
* @phpstan-type OptionsType array{
* layout?: "top"|"topLeft"|"topCenter"|"topRight"|"center"|"centerLeft"|"centerRight"|"bottom"|"bottomLeft"|"bottomCenter"|"bottomRight",
* theme?: "relax"|"mint"|"metroui",
* timeout?: false|int,
* progressBar?: bool,
* closeWith?: string[],
* animation?: array{
* open?: string|null,
* close?: string|null,
* },
* sounds?: array{
* sources?: string[],
* volume?: int,
* conditions?: string[],
* },
* docTitle?: array{
* conditions?: string[],
* },
* modal?: bool,
* id?: bool|string,
* force?: bool,
* queue?: string,
* killer?: bool|string,
* container?: false|string,
* buttons?: string[],
* visibilityControl?: bool,
* }
*/
final class NotyBuilder extends NotificationBuilder
{
/**
* @phpstan-param NotificationType $type
*/
public function type(string $type): static
{
return parent::type($type);
}
/**
* @param OptionsType $options
*/
public function success(string $message, array $options = [], ?string $title = null): Envelope
{
return parent::success($message, $options, $title);
}
/**
* @param OptionsType $options
*/
public function error(string $message, array $options = [], ?string $title = null): Envelope
{
return parent::error($message, $options, $title);
}
/**
* @param OptionsType $options
*/
public function info(string $message, array $options = [], ?string $title = null): Envelope
{
return parent::info($message, $options, $title);
}
/**
* @param OptionsType $options
*/
public function warning(string $message, array $options = [], ?string $title = null): Envelope
{
return parent::warning($message, $options, $title);
}
/**
* @phpstan-param NotificationType $type
* @phpstan-param OptionsType $options
*/
public function flash(?string $type = null, ?string $message = null, array $options = [], ?string $title = null): Envelope
{
return parent::flash($type, $message, $options, $title);
}
/**
* @param OptionsType $options
*/
public function options(array $options, bool $append = true): static
{
return parent::options($options, $append);
}
/**
* @template T of OptionsType
* @template K of key-of<T>
*
* @phpstan-param K $name
* @phpstan-param T[K] $value
*/
public function option(string $name, mixed $value): static
{
return parent::option($name, $value);
}
/**
* This string can contain HTML too. But be careful and don't pass user inputs to this parameter.
*/
@@ -17,7 +117,7 @@ final class NotyBuilder extends NotificationBuilder
}
/**
* @param array<string, mixed> $options
* @param OptionsType $options
*/
public function alert(?string $message = null, ?string $title = null, array $options = []): self
{
@@ -39,7 +139,7 @@ final class NotyBuilder extends NotificationBuilder
}
/**
* @param "top"|"topLeft"|"topCenter"|"topRight"|"center"|"centerLeft"|"centerRight"|"bottom"|"bottomLeft"|"bottomCenter"|"bottomRight" $layout
* @phpstan-param OptionsType['layout'] $layout
*
* - ClassName generator uses this value noty_layout__${layout}
*/
@@ -51,7 +151,7 @@ final class NotyBuilder extends NotificationBuilder
}
/**
* @param "relax"|"mint"|"metroui" $theme
* @phpstan-param OptionsType['theme'] $theme
*
* ClassName generator uses this value noty_theme__${theme}
*/
@@ -65,7 +165,7 @@ final class NotyBuilder extends NotificationBuilder
/**
* false, 1000, 3000, 3500, etc. Delay for closing event in milliseconds (ms). Set 'false' for sticky notifications.
*/
public function timeout(bool|int $timeout): self
public function timeout(false|int $timeout): self
{
$this->option('timeout', $timeout);
@@ -95,35 +195,52 @@ final class NotyBuilder extends NotificationBuilder
}
/**
* @param "open"|"close" $animation
* @param "open"|"close" $option
* @param "noty_effects_open"|"noty_effects_close"|string $effect
*
* If string, assumed to be CSS class name. If null, no animation at all. If function, runs the function. (v3.0.1+)
* You can use animate.css class names or your custom css animations as well.
*/
public function animation(string $animation, string $effect): self
public function animation(string $option, string $effect): self
{
$this->option('animation.'.$animation, $effect);
/** @phpstan-var OptionsType['animation'] $animation */
$animation = $this->getEnvelope()->getOption('animation', []);
$animation[$option] = $effect;
$this->option('animation', $animation);
return $this;
}
/**
* @param "sources"|"volume"|"conditions" $option
* @phpstan-param "sources"|"volume"|"conditions" $option
* @phpstan-param ($option is "sources" ? string[] :
* ($option is "volume" ? int :
* ($option is "conditions" ? string[] :
* mixed))) $value
*/
public function sounds(string $option, mixed $value): self
{
$this->option('sounds.'.$option, $value);
/** @phpstan-var OptionsType['sounds'] $sounds */
$sounds = $this->getEnvelope()->getOption('sounds', []);
$sounds[$option] = $value;
$this->option('sounds', $sounds); // @phpstan-ignore-line
return $this;
}
/**
* @param "conditions"|string $option
* @phpstan-param "conditions"|string $option
* @phpstan-param ($option is "conditions" ? string[] : mixed) $value
*/
public function docTitle(string $option, string $docTitle): self
public function docTitle(string $option, mixed $value): self
{
$this->option('docTitle'.$option, $docTitle);
/** @phpstan-var OptionsType['docTitle'] $docTitle */
$docTitle = $this->getEnvelope()->getOption('docTitle', []);
$docTitle[$option] = $value;
$this->option('docTitle', $docTitle); // @phpstan-ignore-line
return $this;
}
@@ -176,7 +293,7 @@ final class NotyBuilder extends NotificationBuilder
/**
* Custom container selector string. Like '.my-custom-container'. Layout parameter will be ignored.
*/
public function container(bool|string $container): self
public function container(false|string $container): self
{
$this->option('container', $container);
+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
@@ -1,6 +1,6 @@
{
"name": "@flasher/flasher-noty",
"version": "2.0.0",
"version": "2.1.1",
"type": "module",
"license": "MIT",
"main": "dist/flasher-noty.cjs.js",
@@ -11,7 +11,7 @@
"ncu": "ncu -u"
},
"peerDependencies": {
"@flasher/flasher": "^2.0.0",
"@flasher/flasher": "^2.1.1",
"noty": "^3.2.0-beta-deprecated"
}
}
+1 -1
View File
@@ -33,7 +33,7 @@
"prefer-stable": true,
"require": {
"php": ">=8.2",
"php-flasher/flasher": "^2.0.1"
"php-flasher/flasher": "^2.1.1"
},
"autoload": {
"psr-4": {
+30 -4
View File
@@ -16,10 +16,36 @@ if (!\function_exists('Flasher\Noty\Prime\noty')) {
* When called with no arguments, it returns an instance of NotyInterface.
* When called with arguments, it creates a Noty notification and returns an Envelope.
*
* @param string|null $message the message content of the notification
* @param string $type The type of the notification (e.g., success, error, warning, info).
* @param array<string, mixed> $options additional options for the Noty notification
* @param string|null $title the title of the notification
* @param string|null $message the message content of the notification
* @param "success"|"info"|"warning"|"error"|"alert"|"information" $type The type of the notification (e.g., success, error, warning, info).
* @param array{
* layout?: "top"|"topLeft"|"topCenter"|"topRight"|"center"|"centerLeft"|"centerRight"|"bottom"|"bottomLeft"|"bottomCenter"|"bottomRight",
* theme?: "relax"|"mint"|"metroui",
* timeout?: false|int,
* progressBar?: bool,
* closeWith?: string[],
* animation?: array{
* open?: string|null,
* close?: string|null,
* },
* sounds?: array{
* sources?: string[],
* volume?: int,
* conditions?: string[],
* },
* docTitle?: array{
* conditions?: string[],
* },
* modal?: bool,
* id?: bool|string,
* force?: bool,
* queue?: string,
* killer?: bool|string,
* container?: false|string,
* buttons?: string[],
* visibilityControl?: bool,
* } $options additional options for the Noty notification
* @param string|null $title the title of the notification
*
* @return Envelope|NotyInterface Returns an Envelope containing the notification details when arguments are provided.
* Returns an instance of NotyInterface when no arguments are provided.
+30 -4
View File
@@ -15,10 +15,36 @@ if (!function_exists('noty')) {
* When called with no arguments, it returns an instance of NotyInterface.
* When called with arguments, it creates a Noty notification and returns an Envelope.
*
* @param string|null $message the message content of the notification
* @param string $type The type of the notification (e.g., success, error, warning, info).
* @param array<string, mixed> $options additional options for the Noty notification
* @param string|null $title the title of the notification
* @param string|null $message the message content of the notification
* @param "success"|"info"|"warning"|"error"|"alert"|"information" $type The type of the notification (e.g., success, error, warning, info).
* @param array{
* layout?: "top"|"topLeft"|"topCenter"|"topRight"|"center"|"centerLeft"|"centerRight"|"bottom"|"bottomLeft"|"bottomCenter"|"bottomRight",
* theme?: "relax"|"mint"|"metroui",
* timeout?: false|int,
* progressBar?: bool,
* closeWith?: string[],
* animation?: array{
* open?: string|null,
* close?: string|null,
* },
* sounds?: array{
* sources?: string[],
* volume?: int,
* conditions?: string[],
* },
* docTitle?: array{
* conditions?: string[],
* },
* modal?: bool,
* id?: bool|string,
* force?: bool,
* queue?: string,
* killer?: bool|string,
* container?: false|string,
* buttons?: string[],
* visibilityControl?: bool,
* } $options additional options for the Noty notification
* @param string|null $title the title of the notification
*
* @return Envelope|NotyInterface Returns an Envelope containing the notification details when arguments are provided.
* Returns an instance of NotyInterface when no arguments are provided.
+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-noty": "^2.0.1",
"php-flasher/flasher-symfony": "^2.0.1"
"php-flasher/flasher-noty": "^2.1.1",
"php-flasher/flasher-symfony": "^2.1.1"
},
"autoload": {
"psr-4": {
+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
@@ -29,8 +29,8 @@
"prefer-stable": true,
"require": {
"php": ">=8.2",
"php-flasher/flasher-laravel": "^2.0.1",
"php-flasher/flasher-notyf": "^2.0.1"
"php-flasher/flasher-laravel": "^2.1.1",
"php-flasher/flasher-notyf": "^2.1.1"
},
"autoload": {
"psr-4": {
+13
View File
@@ -6,6 +6,19 @@ namespace Flasher\Notyf\Prime;
use Flasher\Prime\Notification\NotificationBuilder;
/**
* @phpstan-type NotificationType "success"|"info"|"warning"|"error"
* @phpstan-type OptionsType array{
* duration?: int,
* ripple?: bool,
* position?: array{
* x: "left"|"center"|"right",
* y: "top"|"center"|"bottom",
* },
* dismissible?: bool,
* background?: string,
* }
*/
final class NotyfBuilder extends NotificationBuilder
{
/**
+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
@@ -1,6 +1,6 @@
{
"name": "@flasher/flasher-notyf",
"version": "2.0.0",
"version": "2.1.1",
"type": "module",
"license": "MIT",
"main": "dist/flasher-notyf.cjs.js",
@@ -11,7 +11,7 @@
"ncu": "ncu -u"
},
"peerDependencies": {
"@flasher/flasher": "^2.0.0",
"@flasher/flasher": "^2.1.1",
"notyf": "^3.10.0"
}
}
+1 -1
View File
@@ -33,7 +33,7 @@
"prefer-stable": true,
"require": {
"php": ">=8.2",
"php-flasher/flasher": "^2.0.1"
"php-flasher/flasher": "^2.1.1"
},
"autoload": {
"psr-4": {
+13 -4
View File
@@ -16,10 +16,19 @@ if (!\function_exists('Flasher\Notyf\Prime\notyf')) {
* When called with no arguments, it returns an instance of NotyfInterface.
* When called with arguments, it creates a Notyf notification and returns an Envelope.
*
* @param string|null $message the message content of the notification
* @param string $type The type of the notification (e.g., success, error, warning, info).
* @param array<string, mixed> $options additional options for the Notyf notification
* @param string|null $title the title of the notification
* @param string|null $message the message content of the notification
* @param "success"|"info"|"warning"|"error" $type The type of the notification (e.g., success, error, warning, info).
* @param array{
* duration?: int,
* ripple?: bool,
* position?: array{
* x: "left"|"center"|"right",
* y: "top"|"center"|"bottom",
* },
* dismissible?: bool,
* background?: string,
* } $options additional options for the Notyf notification
* @param string|null $title the title of the notification
*
* @return Envelope|NotyfInterface Returns an Envelope containing the notification details when arguments are provided.
* Returns an instance of NotyfInterface when no arguments are provided.
+13 -4
View File
@@ -15,10 +15,19 @@ if (!function_exists('notyf')) {
* When called with no arguments, it returns an instance of NotyfInterface.
* When called with arguments, it creates a Notyf notification and returns an Envelope.
*
* @param string|null $message the message content of the notification
* @param string $type The type of the notification (e.g., success, error, warning, info).
* @param array<string, mixed> $options additional options for the Notyf notification
* @param string|null $title the title of the notification
* @param string|null $message the message content of the notification
* @param "success"|"info"|"warning"|"error" $type The type of the notification (e.g., success, error, warning, info).
* @param array{
* duration?: int,
* ripple?: bool,
* position?: array{
* x: "left"|"center"|"right",
* y: "top"|"center"|"bottom",
* },
* dismissible?: bool,
* background?: string,
* } $options additional options for the Notyf notification
* @param string|null $title the title of the notification
*
* @return Envelope|NotyfInterface Returns an Envelope containing the notification details when arguments are provided.
* Returns an instance of NotyfInterface when no arguments are provided.
+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
@@ -29,8 +29,8 @@
"prefer-stable": true,
"require": {
"php": ">=8.2",
"php-flasher/flasher-notyf": "^2.0.1",
"php-flasher/flasher-symfony": "^2.0.1"
"php-flasher/flasher-notyf": "^2.1.1",
"php-flasher/flasher-symfony": "^2.1.1"
},
"autoload": {
"psr-4": {
+1
View File
@@ -20,3 +20,4 @@ expectedReturnValues(\Flasher\Prime\Notification\NotificationInterface::getType(
expectedArguments(\Flasher\Prime\Notification\NotificationBuilderInterface::handler(), 0, 'flasher', 'toastr', 'noty', 'notyf', 'sweetalert');
expectedArguments(\Flasher\Prime\FlasherInterface::render(), 0, 'html', 'json', 'array');
expectedArguments(\Flasher\Prime\Notification\FlasherBuilder::option(), 0, 'timeout', 'timeouts', 'fps', 'position', 'direction', 'rtl', 'style', 'escapeHtml');
+67
View File
@@ -0,0 +1,67 @@
<?php
declare(strict_types=1);
namespace Flasher\Prime;
/**
* @phpstan-type ConfigType array{
* default: string,
* main_script?: string,
* scripts?: string[],
* styles?: string[],
* inject_assets?: bool,
* translate?: bool,
* excluded_paths?: list<non-empty-string>,
* options?: array<string, mixed>,
* filter?: array<string, mixed>,
* flash_bag?: false|array<string, string[]>,
* presets?: array<string, array{
* type: string,
* title: string,
* message: string,
* options: array<string, mixed>,
* }>,
* plugins?: array<string, array{
* scripts?: string[],
* styles?: string[],
* options?: array<string, mixed>,
* }>,
* }
*/
final class Configuration
{
/**
* @param array{
* default: string,
* main_script?: string,
* scripts?: string[],
* styles?: string[],
* inject_assets?: bool,
* translate?: bool,
* excluded_paths?: list<non-empty-string>,
* options?: array<string, mixed>,
* filter?: array<string, mixed>,
* flash_bag?: false|array<string, string[]>,
* presets?: array<string, array{
* type: string,
* title: string,
* message: string,
* options: array<string, mixed>,
* }>,
* plugins?: array<string, array{
* scripts?: string[],
* styles?: string[],
* options?: array<string, mixed>,
* }>,
* } $config
*
* @phpstan-param ConfigType $config
*
* @return ConfigType
*/
public static function from(array $config): array
{
return $config;
}
}
@@ -4,30 +4,33 @@ declare(strict_types=1);
namespace Flasher\Prime\EventDispatcher\Event;
use Flasher\Prime\Notification\NotificationInterface;
use Flasher\Prime\Notification\Envelope;
/**
* @internal
*/
final class NotificationEvents
{
/** @var NotificationInterface[] */
private array $notifications = [];
/** @var Envelope[] */
private array $envelopes = [];
public function add(NotificationInterface ...$notifications): void
public function add(Envelope ...$notifications): void
{
foreach ($notifications as $notification) {
$this->addNotification($notification);
$this->addEnvelope($notification);
}
}
public function addNotification(NotificationInterface $notification): void
public function addEnvelope(Envelope $notification): void
{
$this->notifications[] = $notification;
$this->envelopes[] = $notification;
}
/**
* @return NotificationInterface[]
* @return Envelope[]
*/
public function getNotifications(): array
public function getEnvelopes(): array
{
return $this->notifications;
return $this->envelopes;
}
}
@@ -5,34 +5,69 @@ declare(strict_types=1);
namespace Flasher\Prime\EventDispatcher\EventListener;
use Flasher\Prime\EventDispatcher\Event\NotificationEvents;
use Flasher\Prime\EventDispatcher\Event\PersistEvent;
use Flasher\Prime\EventDispatcher\Event\PresentationEvent;
/**
* @internal
*/
final class NotificationLoggerListener implements EventListenerInterface
{
private NotificationEvents $events;
private NotificationEvents $dispatchedEnvelopes;
private NotificationEvents $displayedEnvelopes;
public function __construct()
{
$this->events = new NotificationEvents();
$this->dispatchedEnvelopes = new NotificationEvents();
$this->displayedEnvelopes = new NotificationEvents();
}
public function reset(): void
{
$this->events = new NotificationEvents();
$this->dispatchedEnvelopes = new NotificationEvents();
$this->displayedEnvelopes = new NotificationEvents();
}
public function __invoke(PresentationEvent $event): void
public function __invoke(object $event): void
{
$this->events->add(...$event->getEnvelopes());
if ($event instanceof PersistEvent) {
$this->onPersist($event);
}
if ($event instanceof PresentationEvent) {
$this->onPresentation($event);
}
}
public function getEvents(): NotificationEvents
public function onPersist(PersistEvent $event): void
{
return $this->events;
$this->dispatchedEnvelopes->add(...$event->getEnvelopes());
}
public function getSubscribedEvents(): string
public function onPresentation(PresentationEvent $event): void
{
return PresentationEvent::class;
$this->displayedEnvelopes->add(...$event->getEnvelopes());
}
public function getDispatchedEnvelopes(): NotificationEvents
{
return $this->dispatchedEnvelopes;
}
public function getDisplayedEnvelopes(): NotificationEvents
{
return $this->displayedEnvelopes;
}
/**
* @return string[]
*/
public function getSubscribedEvents(): array
{
return [
PersistEvent::class,
PresentationEvent::class,
];
}
}
+1 -1
View File
@@ -15,7 +15,7 @@ final readonly class Flasher implements FlasherInterface
{
use ForwardsCalls;
public const VERSION = '2.0.0';
public const VERSION = '2.1.1';
public function __construct(
private string $default,
+1 -1
View File
@@ -8,7 +8,7 @@ use Flasher\Prime\Factory\NotificationFactoryInterface;
use Flasher\Prime\Response\Presenter\ArrayPresenter;
/**
* @mixin \Flasher\Prime\Notification\FlasherBuilder
* @mixin \Flasher\Prime\Notification\NotificationBuilder
*
* @phpstan-import-type ArrayPresenterType from ArrayPresenter
*/
+5
View File
@@ -4,8 +4,13 @@ declare(strict_types=1);
namespace Flasher\Prime\Http;
/**
* @method string getUri()
*/
interface RequestInterface
{
// public function getUri(): string;
public function isXmlHttpRequest(): bool;
public function isHtmlRequestFormat(): bool;
+27 -3
View File
@@ -10,8 +10,14 @@ use Flasher\Prime\Response\Presenter\HtmlPresenter;
final readonly class ResponseExtension implements ResponseExtensionInterface
{
public function __construct(private FlasherInterface $flasher, private ContentSecurityPolicyHandlerInterface $cspHandler)
{
/**
* @param list<non-empty-string> $excludedPaths
*/
public function __construct(
private FlasherInterface $flasher,
private ContentSecurityPolicyHandlerInterface $cspHandler,
private array $excludedPaths = [],
) {
}
public function render(RequestInterface $request, ResponseInterface $response): ResponseInterface
@@ -69,7 +75,8 @@ final readonly class ResponseExtension implements ResponseExtensionInterface
private function isRenderable(RequestInterface $request, ResponseInterface $response): bool
{
return !$request->isXmlHttpRequest()
return !$this->isPathExcluded($request)
&& !$request->isXmlHttpRequest()
&& $request->isHtmlRequestFormat()
&& $response->isHtml()
&& $response->isSuccessful()
@@ -77,4 +84,21 @@ final readonly class ResponseExtension implements ResponseExtensionInterface
&& !$response->isAttachment()
&& !$response->isJson();
}
private function isPathExcluded(RequestInterface $request): bool
{
if (!method_exists($request, 'getUri')) { // @phpstan-ignore-line
return false;
}
$url = $request->getUri();
foreach ($this->excludedPaths as $regexPattern) {
if (preg_match($regexPattern, $url)) {
return true;
}
}
return false;
}
}
+4 -1
View File
@@ -103,7 +103,10 @@ final class Envelope implements NotificationInterface
*/
public function get(string $type): ?StampInterface
{
return $this->stamps[$type] ?? null; // @phpstan-ignore-line
/** @var T|null $stamp */
$stamp = $this->stamps[$type] ?? null;
return $stamp;
}
/**
+88
View File
@@ -4,8 +4,90 @@ declare(strict_types=1);
namespace Flasher\Prime\Notification;
/**
* @phpstan-type NotificationType "success"|"info"|"warning"|"error"
* @phpstan-type OptionsType array{
* timeout?: int,
* timeouts?: array<string, int>,
* fps?: int,
* position?: "top-right"|"top-left"|"top-center"|"bottom-right"|"bottom-left"|"bottom-center",
* direction?: "top"|"bottom",
* rtl?: bool,
* style?: array<string, mixed>,
* escapeHtml?: bool,
* }
*/
final class FlasherBuilder extends NotificationBuilder
{
/**
* @phpstan-param NotificationType $type
*/
public function type(string $type): static
{
return parent::type($type);
}
/**
* @param OptionsType $options
*/
public function success(string $message, array $options = [], ?string $title = null): Envelope
{
return parent::success($message, $options, $title);
}
/**
* @param OptionsType $options
*/
public function error(string $message, array $options = [], ?string $title = null): Envelope
{
return parent::error($message, $options, $title);
}
/**
* @param OptionsType $options
*/
public function info(string $message, array $options = [], ?string $title = null): Envelope
{
return parent::info($message, $options, $title);
}
/**
* @param OptionsType $options
*/
public function warning(string $message, array $options = [], ?string $title = null): Envelope
{
return parent::warning($message, $options, $title);
}
/**
* @phpstan-param NotificationType $type
* @phpstan-param OptionsType $options
*/
public function flash(?string $type = null, ?string $message = null, array $options = [], ?string $title = null): Envelope
{
return parent::flash($type, $message, $options, $title);
}
/**
* @param OptionsType $options
*/
public function options(array $options, bool $append = true): static
{
return parent::options($options, $append);
}
/**
* @template T of OptionsType
* @template K of key-of<T>
*
* @phpstan-param K $name
* @phpstan-param T[K] $value
*/
public function option(string $name, mixed $value): static
{
return parent::option($name, $value);
}
public function timeout(int $milliseconds): self
{
$this->option('timeout', $milliseconds);
@@ -13,6 +95,9 @@ final class FlasherBuilder extends NotificationBuilder
return $this;
}
/**
* @param "top"|"bottom" $direction
*/
public function direction(string $direction): self
{
$this->option('direction', $direction);
@@ -20,6 +105,9 @@ final class FlasherBuilder extends NotificationBuilder
return $this;
}
/**
* @phpstan-param OptionsType['position'] $position
*/
public function position(string $position): self
{
$this->option('position', $position);
+7
View File
@@ -14,6 +14,7 @@ use Flasher\Prime\Notification\Type;
* main_script: string,
* translate: bool,
* inject_assets: bool,
* excluded_paths: list<non-empty-string>,
* scripts: string[],
* styles: string[],
* options: array<string, mixed>,
@@ -188,6 +189,7 @@ final class FlasherPlugin extends Plugin
* main_script?: string|null,
* translate?: bool,
* inject_assets?: bool,
* excluded_paths?: list<non-empty-string>,
* filter?: array<string, mixed>,
* scripts: string[],
* styles: string[],
@@ -201,6 +203,7 @@ final class FlasherPlugin extends Plugin
* main_script: string|null,
* translate: bool,
* inject_assets: bool,
* excluded_paths?: list<non-empty-string>,
* filter: array<string, mixed>,
* scripts: string[],
* styles: string[],
@@ -234,6 +237,7 @@ final class FlasherPlugin extends Plugin
* main_script: string|null,
* translate: bool,
* inject_assets: bool,
* excluded_paths?: list<non-empty-string>,
* filter: array<string, mixed>,
* scripts: string[],
* styles: string[],
@@ -248,6 +252,7 @@ final class FlasherPlugin extends Plugin
* main_script: string|null,
* translate: bool,
* inject_assets: bool,
* excluded_paths?: list<non-empty-string>,
* filter: array<string, mixed>,
* scripts: string[],
* styles: string[],
@@ -285,6 +290,7 @@ final class FlasherPlugin extends Plugin
* main_script: string|null,
* translate: bool,
* inject_assets: bool,
* excluded_paths?: list<non-empty-string>,
* filter: array<string, mixed>,
* scripts: string[],
* styles: string[],
@@ -299,6 +305,7 @@ final class FlasherPlugin extends Plugin
* main_script: string|null,
* translate: bool,
* inject_assets: bool,
* excluded_paths?: list<non-empty-string>,
* filter: array<string, mixed>,
* scripts: string[],
* styles: string[],
+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">
@@ -15,7 +15,6 @@ html.fl-dark .fl-flasher {
margin: 0.75em 0;
position: relative;
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
border: 1px solid rgba(0, 0, 0, 0.03);
border-bottom: none;
&.fl-rtl {
+5 -4
View File
@@ -1,3 +1,4 @@
@use "sass:meta";
:root {
--background-color: rgb(255, 255, 255);
--text-color: rgb(75, 85, 99);
@@ -13,7 +14,7 @@
--error-color-light: hsl(0deg, 75%, 90%);
}
@import "wrapper";
@import "container";
@import "icons";
@import "progress";
@include meta.load-css("wrapper");
@include meta.load-css("container");
@include meta.load-css("icons");
@include meta.load-css("progress");
File diff suppressed because one or more lines are too long

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