Download the PHP package mattlibera/livewire-flash without Composer

On this page you can find all versions of the php package mattlibera/livewire-flash. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package livewire-flash

Livewire Flash

This package provides flash message capability using Laravel Livewire. It is based very literally on laracasts/flash but has been extended to add the ability to flash a message to a the flash container (a Livewire component) without reloading the page.

This package also retains much (though not all) of the same capability for "normal" flash messages, which are displayed on refresh by the same Livewire component.

Installation

Install via composer:

Requirements

For new applications, consider using the TALL preset for Laravel: [https://github.com/laravel-frontend-presets/tall], or this package also works well with Laravel Jetstream: [https://jetstream.laravel.com/]

Recommended add-ons

Out of the box, the default alert component uses:

However, it's fairly trivial to implement your own views / styles instead, by publishing the config and overriding defaults. See below for more on that.

Tailwind setup

If you are using Tailwind CSS, you'll likely want to amend the content section of your tailwind.config.js to include the appropriate files from this package:

Of course, if you publsh the views/config, you'll reference your own copies instead.

Usage

Normal flash messages (on reload)

Call the flash() helper from your code somewhere, before you redirect.

Livewire flash message (before reload)

From your Livewire component, flash your message using the normal syntax, but then call the livewire() helper method as the last method in the chain. You must pass in $this as the argument, as this package utilizes the emit helper that exists on all Livewire components. Example:

Message types

Message types are defined in the livewire-flash.php config file, which can be published (see below) if desired. By default, there are four supported message types: info (default if nothing else is specified), success, warning, and error.

To set a message's type, either:

  1. Pass it as the second argument to flash() - example: flash('Your action succeeded', 'success'), or
  2. Chain it as a method name fluently after flash() - example: flash('Your action succeeded')->success()

Both of those will change the message's display (colors and icon) to the configured styles.

Overlay Message

Overlay message is defined in the livewire-flash.php config file, which can be published (see below) if desired.

To set an overlay message, chain the method name overlay() after flash(). When using overlay leave the flash() parameter empty. Enter your message as the first parameter and title as second parameter for overlay(). This can be used with or without the livewire($this) suffix:

Note that the out-of-the-box overlay component does support HTML code for the body and title, using the Blade unescaped {!! !!} tags.

Customization

To change the styles used by each message type, OR to add your own types, first publish the config file:

Then, in the styles key you can change whatever you want:

Or you can add your own:

Whatever the case, just ensure that you call the alert by its config key: flash('An important message')->notice()

To customize overlay styles, see the overlay key of the config file.

Templates

Out of the box, the Livewire Flash Container component is registered for you. All you have to do is include it in your template:

There are also some sample alert components (styled using TailwindCSS) included with this package. However, if you do not wish to use those...

Customization

You can change the views that the Livewire components use for rendering, and the styles applied to each message type.

If you are not using TailwindCSS and/or FontAwesome, you should definitely do this to call your own alert component/partial to fit whatever your stack is using.

First, publish the config file:

Then, edit the views area:

You can access the public message properties on MattLibera\LivewireFlash\Message, as well as $styles (which is injected via the Livewire component) in your template.

Dismissable Messages

By default, each message will be set to be dismissable (that is, have an X icon at the right that will close the alert). If you wish to prevent this, you can chain ->notDismissable() (or ->dismissable(false)) to your flash directive.

You can add your own magic via AlpineJS or whatever else if you want to fade messages out automatically - right now each message is a Livewire component and uses Livewire logic to hide it when it is dismissed.

Note that the overlay does not support this directive.

Multiple Flash Messages

Multiple flash messages can be sent to the session:

OR

However, at the moment, because of the way Livewire handles the session, you cannot mix-and-match... that is, you cannot do:

Contributing

I am open to contributions to this package, and will do the best I can to maintain it over time. Pull requests are welcome, and in fact encouraged. Right now there are no specific guidelines for a PR.

Road Map

Some considerations for future versions:

Credits and License

Credit for the original package goes to Jeffrey Way and Laracasts. Additional thanks:

This is an MIT-licensed package. Please read license.md for the details.


All versions of livewire-flash with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3.0
illuminate/support Version ^7.0|^8.0|^9.0|^10.0|^11.0
livewire/livewire Version ^1.2|^2.12.7|^3.5.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mattlibera/livewire-flash contains the following files

Loading the files please wait ....