From 22e664f4168acda89dbc90d380d0c829d1b72a70 Mon Sep 17 00:00:00 2001 From: Khoubza Younes Date: Fri, 30 Dec 2022 12:58:54 +0100 Subject: [PATCH] add more description to laravel config file --- Makefile | 1 + bin/build | 9 --- make/build.mk | 8 +++ make/lint.mk | 3 + src/Laravel/Resources/config.php | 112 ++++++++++++++++++++++++------- 5 files changed, 99 insertions(+), 34 deletions(-) delete mode 100755 bin/build create mode 100644 make/build.mk diff --git a/Makefile b/Makefile index 567e05ca..8f9e7509 100644 --- a/Makefile +++ b/Makefile @@ -2,3 +2,4 @@ include make/variables.mk include make/help.mk include make/composer.mk include make/lint.mk +include make/build.mk diff --git a/bin/build b/bin/build deleted file mode 100755 index f59891ad..00000000 --- a/bin/build +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -composer normalize -find src -name "composer.json" -exec composer normalize {} \; - -composer validate -find src -name "composer.json" -exec composer validate {} \; - -bin/assets diff --git a/make/build.mk b/make/build.mk new file mode 100644 index 00000000..ae7e51ec --- /dev/null +++ b/make/build.mk @@ -0,0 +1,8 @@ +.PHONY: assets build + +## Download local assets from cdn +assets: + bin/assets + +# Build a new PHPFlasher version +build: lint assets diff --git a/make/lint.mk b/make/lint.mk index 9c4fd691..32b3527b 100644 --- a/make/lint.mk +++ b/make/lint.mk @@ -4,7 +4,10 @@ lint: test `find ./src -iname "*.php" | xargs -n1 -P6 php -l | grep -Fv "No syntax errors" | wc -l` -eq 0 $(PHP_CS_FIXER) fix --diff --dry-run -v + $(COMPOSER) normalize + find src -name "composer.json" -exec $(COMPOSER) normalize {} \; $(COMPOSER) validate --strict + find src -name "composer.json" -exec $(COMPOSER) validate --strict {} \; ## Fix files with php-cs-fixer fix: diff --git a/src/Laravel/Resources/config.php b/src/Laravel/Resources/config.php index d554db20..91c8f745 100644 --- a/src/Laravel/Resources/config.php +++ b/src/Laravel/Resources/config.php @@ -8,13 +8,20 @@ return array( /* |-------------------------------------------------------------------------- - | Default PHPFlasher driver + | Default PHPFlasher library |-------------------------------------------------------------------------- - | This option controls the default driver that will be used by PHPFlasher. + | This option controls the default library that will be used by PHPFlasher + | to display notifications in your Laravel application. PHPFlasher supports + | several libraries, including "flasher", "toastr", "noty", "notyf", + | "sweetalert" and "pnotify". | - | Supported drivers: "flasher", "toastr", "noty", "sweetalert", "pnotify" + | The "flasher" library is used by default. If you want to use a different + | library, you will need to install it using composer. For example, to use + | the "toastr" library, run the following command: + | composer require php-flasher/flasher-toastr-laravel | - | Only "flasher" is supported by default, but you can install other options using composer. + | Here is a list of the supported libraries and the corresponding composer + | commands to install them: | | "toastr" : composer require php-flasher/flasher-toastr-laravel | "noty" : composer require php-flasher/flasher-noty-laravel @@ -28,10 +35,19 @@ return array( |-------------------------------------------------------------------------- | Main PHPFlasher javascript file |-------------------------------------------------------------------------- - | This is the main javascript file that will be included in the page ony - | when a notification is ready to be displayed, by defaut PHPFlasher - | use a CDN with the latest version of the library. but you - | could download it locally or install it with npm. + | This option specifies the location of the main javascript file that is + | required by PHPFlasher to display notifications in your Laravel application. + | + | By default, PHPFlasher uses a CDN to serve the latest version of the library. + | However, you can also choose to download the library locally or install it + | using npm. + | + | To use the local version of the library, run the following command: + | php artisan vendor:publish --force --tag=flasher-assets + | + | This will copy the necessary assets to your application's public folder. + | You can then specify the local path to the javascript file in the 'local' + | field of this option. */ 'root_script' => array( 'cdn' => 'https://cdn.jsdelivr.net/npm/@flasher/flasher@1.2.4/dist/flasher.min.js', @@ -42,11 +58,16 @@ return array( |-------------------------------------------------------------------------- | Whether to use CDN for PHPFlasher assets or not |-------------------------------------------------------------------------- - | By default PHPFlasher use CDN for all assets, to use local version of - | the assets set use_cdn to false. + | This option controls whether PHPFlasher should use CDN links or local assets + | for its javascript and CSS files. By default, PHPFlasher uses CDN links + | to serve the latest version of the library. However, you can also choose + | to use local assets by setting this option to 'false'. | - | Don't forget to publish your assets with: + | If you decide to use local assets, don't forget to publish the necessary + | files to your application's public folder by running the following command: | php artisan vendor:publish --force --tag=flasher-assets + | + | This will copy the necessary assets to your application's public folder. */ 'use_cdn' => true, @@ -54,8 +75,15 @@ return array( |-------------------------------------------------------------------------- | Translate PHPFlasher messages |-------------------------------------------------------------------------- - | By default PHPFlasher messages are passed to Laravel translator service - | to disable this behavior, set this option to `false`. + | This option controls whether PHPFlasher should pass its messages to the Laravel's + | translation service for localization. + | + | By default, this option is set to 'true', which means that PHPFlasher will + | attempt to translate its messages using the translation service. + | + | If you don't want PHPFlasher to use the Laravel's translation service, you can + | set this option to 'false'. In this case, PHPFlasher will use the messages + | as-is, without attempting to translate them. */ 'auto_translate' => true, @@ -63,8 +91,16 @@ return array( |-------------------------------------------------------------------------- | Inject PHPFlasher in Response |-------------------------------------------------------------------------- - | PHPFlasher scripts are added automatically before , by listening - | to the Response after the App is done. + | This option controls whether PHPFlasher should automatically inject its + | javascript and CSS files into the HTML response of your Laravel application. + | + | By default, this option is set to 'true', which means that PHPFlasher will + | listen to the response of your application and automatically insert its + | scripts and stylesheets into the HTML before the closing `` tag. + | + | If you don't want PHPFlasher to automatically inject its scripts and stylesheets + | into the response, you can set this option to 'false'. In this case, you will + | need to manually include the necessary files in your application's layout. */ 'auto_render' => true, @@ -73,10 +109,15 @@ return array( |----------------------------------------------------------------------- | Enable flash bag |----------------------------------------------------------------------- - | This option allows you to automatically convert Laravel's flash - | messages to PHPFlasher notifications. This is useful when - | you want to migrate from a Legacy system or another - | library similar to PHPFlasher. + | This option controls whether PHPFlasher should automatically convert + | Laravel's flash messages to PHPFlasher notifications. This feature is + | useful when you want to migrate from a legacy system or another + | library that uses similar conventions for flash messages. + | + | When this option is set to 'true', PHPFlasher will check for flash + | messages in the session and convert them to notifications using the + | mapping specified in the 'mapping' option. When this option is set + | to 'false', PHPFlasher will ignore flash messages in the session. */ 'enabled' => true, @@ -85,9 +126,14 @@ return array( | Flash bag type mapping |----------------------------------------------------------------------- | This option allows you to map or convert session keys to PHPFlasher - | notification types. on the right side are the PHPFlasher types - | On the left side are the Laravel session keys that you - | want to convert to PHPFlasher types. + | notification types. On the left side are the PHPFlasher types. + | On the right side are the Laravel session keys that you want to + | convert to PHPFlasher types. + | + | For example, if you want to convert Laravel's 'danger' flash + | messages to PHPFlasher's 'error' notifications, you can add + | the following entry to the mapping: + | 'error' => ['danger'], */ 'mapping' => array( 'success' => array('success'), @@ -102,10 +148,26 @@ return array( | Global Filter Criteria |----------------------------------------------------------------------- | This option allows you to filter the notifications that are displayed - | by default all notifications are displayed, but you can filter - | them, for example to only display errors. + | in your Laravel application. By default, all notifications are displayed, + | but you can use this option to limit the number of notifications or + | filter them by type. + | + | For example, to limit the number of notifications to 5, you can set + | the 'limit' field to 5: + | 'limit' => 5, + | + | To filter the notifications by type, you can specify an array of + | types that you want to display. For example, to only display + | error notifications, you can set the 'types' field to ['error']: + | 'types' => ['error'], + | + | You can also combine multiple criteria by specifying multiple fields. + | For example, to display up to 5 error notifications, you can set + | the 'limit' and 'types' fields like this: + | 'limit' => 5, + | 'types' => ['error'], */ 'filter_criteria' => array( - // 'limit' => 5, // Limit the number of notifications to display + 'limit' => 5, // Limit the number of notifications to display ), );