{"id":14974754,"url":"https://github.com/apphp/laravel-flash","last_synced_at":"2025-10-27T09:31:30.262Z","repository":{"id":56949531,"uuid":"246925342","full_name":"apphp/laravel-flash","owner":"apphp","description":"This package allows to use Bootstrap flash messaging for Laravel framework applications.","archived":false,"fork":false,"pushed_at":"2023-07-24T14:46:29.000Z","size":155,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-05T08:56:09.428Z","etag":null,"topics":["apphp","flash-messages","laravel","laravel-package","laravel6","laravel6-package","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apphp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-12T20:30:53.000Z","updated_at":"2023-07-25T07:11:38.000Z","dependencies_parsed_at":"2024-09-23T16:02:10.060Z","dependency_job_id":"0ecabc67-3246-4c6e-88e7-2b4a9fb29845","html_url":"https://github.com/apphp/laravel-flash","commit_stats":{"total_commits":87,"total_committers":2,"mean_commits":43.5,"dds":0.3793103448275862,"last_synced_commit":"ddb1a38925b3b55a6814b9de71f510e660d6093a"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apphp%2Flaravel-flash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apphp%2Flaravel-flash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apphp%2Flaravel-flash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apphp%2Flaravel-flash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apphp","download_url":"https://codeload.github.com/apphp/laravel-flash/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238472031,"owners_count":19478147,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apphp","flash-messages","laravel","laravel-package","laravel6","laravel6-package","php"],"created_at":"2024-09-24T13:51:02.151Z","updated_at":"2025-10-27T09:31:29.890Z","avatar_url":"https://github.com/apphp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://opensource.org/licenses/MIT)\n\n\n# Simple Flash Messages for Laravel Framework Applications\n\nThis package allows to use Bootstrap 3/4/5 flash messaging for Laravel 6+ framework applications.\n\n\n## Requirements\n\n* PHP \u003e=7.1\n* Laravel 6+\n* Bootstrap 3+\n\n\n## License\n\nThis project is released under the MIT License.   \nCopyright © 2020 [ApPHP](https://www.apphp.com/).\n\n\n## Installation\n\nBegin by pulling in the package through Composer.\n\n```bash\ncomposer require apphp/laravel-flash\n```\n\nNext, make sure the default CSS classes for your flash message are optimized for Bootstrap. You may either pull in the Bootstrap's CSS \nwithin your HTML or layout file, or write your own CSS classes based on them. If you use Bootstrap 3, part of classes, like \"primary\" and \n\"secondary\" will not have styling. \n\n```html\n\u003clink rel=\"stylesheet\" href=\"//getbootstrap.com/docs/4.0/dist/css/bootstrap.min.css\"\u003e\n```\n\n\n## Usage\n\nIn your controllers, before you perform a redirect or render a view, make a call to the `flash()` function.\n\n```php\npublic function store()\n{\n    flash('Welcome Message!');\n\n    return redirect()-\u003eroute('home');\n}\n```\n\nThe general way to define a flash message is a following:\n```php\nflash()-\u003edanger('The error message')-\u003eimportant();\nflash()-\u003einfo('The info message');\n```\n![Simple message](https://raw.githubusercontent.com/apphp/laravel-flash/master/images/message-simple.png)\n\nIf you want to specify a title for alert, pass 2 arguments in the following way:\n```php\nflash()-\u003esuccess(['Success', 'Operation has been successfully completed']);\n```\n![Message with title](https://raw.githubusercontent.com/apphp/laravel-flash/master/images/message-with-title.png)\n\n\nBut you may use a shorter syntax:\n```php\nflash(['Error', 'The error message'], 'error', true);\nflash('The info message', true);\nflash('The info message');\n```\n\nYou may also define the following flash messages:\n\n| Method                                    | Description                                                               |\n|-------------------------------------------|---------------------------------------------------------------------------|\n| `flash('your-message', 'primary')`        | Set the flash type to \"primary\".                                          |\n| `flash('your-message', 'secondary')`      | Set the flash type to \"secondary\".                                        |\n| `flash('your-message', 'success')`        | Set the flash type to \"success\".                                          |\n| `flash('your-message', 'warning')`        | Set the flash type to \"warning\".                                          |\n| `flash('your-message', 'validation')`     | Set the flash type to \"validation\".                                       |\n| `flash('your-message', 'info')`           | Set the flash type to \"info\".                                             |\n| `flash('your-message', 'danger')`         | Set the flash type to \"danger\".                                           |\n| `flash('your-message', 'error')`          | Set the flash type to \"error\" (alias to \"danger\") w/o a close button.     |\n| `flash('your-message', 'error', true)`    | Set the flash type to \"error\" with a close button to the message.         |\n| `flash('your-message', 'light')`          | Set the flash type to \"light\".                                            |\n| `flash('your-message', 'dark')`           | Set the flash type to \"dark\".                                            |\n\nYou may also define messages, by using Flash facade:\n```php\nuse Apphp\\Flash\\Flash;\n```\n\n| Method                                    | Description                                                                |\n|-------------------------------------------|----------------------------------------------------------------------------|\n| `Flash::success('your-message')`          | Set the success flash message.                                             |\n| `Flash::error('your-message')`            | Set the flash type to \"error\" w/o a close button to the message.           |\n| `Flash::error('your-message', true)`      | Set the flash type to \"error\" with a close button to the message.          |\netc.\n\n\nTo show messages on view files, use the following:\n\n```html\n@include('flash::message')\n```\n\nIf you need to modify the flash message, you can run:\n\n```bash\nphp artisan vendor:publish --provider=\"Apphp\\Flash\\FlashServiceProvider\"\n```\n\n\n## Show Multiple Messages\n\nIf you need to flash multiple flash messages, you may simply define them one after another.\n\n```php\nflash('First Message', 'success');\nflash('Second Message', 'warning', true);\n\nreturn redirect('somewhere');\n```\n\nTake in account, that you'll not see flash messages if you don't perform redirect.\n\n\n## Clear Messages\n\nIf you need to clear flash messages, you may do it in the following way:\n\n```php\n// All previously defined messages will be removed\nflash('First Message', 'error');\nflash('Second Message', 'danger')-\u003eclear();\n\n// All previously defined messages will be removed\nflash('First Message', 'error');\nflash('Second Message', 'danger');\nFlash::success('Third Message');\nflash()-\u003eclear();\n\nFlash::success('First Message');\n// Only current message will be removed\nFlash::error('Second Message')-\u003eclear();\n\nreturn redirect('somewhere');\n```\n\n## Hide Messages\n\nGenerally you're expecting from the flash messages to be shown for a few seconds, and then they will be closed (if this message is not important). \nTo handle such behaviour, you may write a simple JavaScript code. For example, using jQuery, you might add the following snippet just before \nthe closing `\u003c/body\u003e` tag.\n\n```html\n\u003cscript\u003e\n    $('div.alert').not('.alert-important').delay(5000).fadeOut(250);\n\u003c/script\u003e\n```\n\nor with pure CSS\n\n```html\n\u003cstyle\u003e\ndiv.alert:not(.alert-important) {\n    -webkit-animation: cssAnimation 5s forwards;\n    animation: cssAnimation 5s forwards;\n}\n@keyframes cssAnimation {\n    0%   {opacity: 1; height:auto; padding: 0.75rem 1.25rem; margin-bottom: 1rem;}\n    90%  {opacity: 1; height:auto; padding: 0.75rem 1.25rem; margin-bottom: 1rem;}\n    100% {opacity: 0; height:0; padding:0; margin:0;}\n}\n@-webkit-keyframes cssAnimation {\n    0%   {opacity: 1; height:auto; padding: 0.75rem 1.25rem; margin-bottom: 1rem;}\n    90%  {opacity: 1; height:auto; padding: 0.75rem 1.25rem; margin-bottom: 1rem;}\n    100% {opacity: 0; height:0; padding:0; margin:0;}\n}\n\u003c/style\u003e\n``` \n\n## Configuration\n\nTo change default messages and enable some extra features you can export the config file:\n```bash\nphp artisan vendor:publish --tag=laravel-flash:config\n```\n\n## Customize Views \n\nTo change HTML template of the message or use your own, publish view file and customize it to suit your needs.\n```bash\n$ php artisan vendor:publish --tag=laravel-flash:views\n```\nNow you should have a flash.php file in the config folder of your application. If you need to force to re-publish the config file to use `--force`.\n\n\n## Testing \n\nTo rum unit testing simply do following:\n```bash\n./vendor/bin/phpunit vendor\\\\apphp\\\\laravel-flash\\\\tests\\\\TestFlashMessage.php\n```\n\nor your may add additional section to your composer.json file:\n```json\n\"scripts\": {\n    \"tests\": \"phpunit --colors=always\",\n    \"test\": \"phpunit --colors=always --filter\",\n}\n```\n\nand then rum unit following command:\n```bash\ncomposer tests vendor\\\\apphp\\\\laravel-flash\\\\tests\\\\TestFlashMessage.php\n ```\n\n## Example\n\nThis package doesn't includes Bootstrap or any other styling or frontend assets frameworks, so you need to import all the necessary stylesheets.\n\n```html\n\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\"\u003e\n\u003chead\u003e\n    \u003cmeta charset=\"UTF-8\"\u003e\n    \u003ctitle\u003eDocument Title\u003c/title\u003e\n    \u003clink rel=\"stylesheet\" href=\"https://getbootstrap.com/docs/4.0/dist/css/bootstrap.min.css\"\u003e\n\u003c/head\u003e\n\u003cbody\u003e\n\n\u003cdiv class=\"container\"\u003e\n    @include('flash::message')\n\n    \u003cp\u003eWelcome to my website...\u003c/p\u003e\n\u003c/div\u003e\n\n\u003cscript src=\"https://code.jquery.com/jquery-3.3.1.slim.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js\"\u003e\u003c/script\u003e\n\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n#### All Types of Messages\n![All Types of Messages](https://raw.githubusercontent.com/apphp/laravel-flash/master/images/messages-all-types.png)\n\n#### Messages with Titles\n![All Types of Messages](https://raw.githubusercontent.com/apphp/laravel-flash/master/images/messages-with-titles.png)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapphp%2Flaravel-flash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapphp%2Flaravel-flash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapphp%2Flaravel-flash/lists"}