Download the PHP package coderello/laraflash without Composer

On this page you can find all versions of the php package coderello/laraflash. 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 laraflash

Laraflash

Laraflash provides a handy way to work with the flash messages.

Latest Version StyleCI Quality Score Coverage Status

Installation

You can install this package via composer using this command:

After that you need to register the \Coderello\Laraflash\Middleware\HandleLaraflash::class middleware after the \Illuminate\Session\Middleware\StartSession::class one in the app\Http\Kernel.php

You can publish the config file with:

Adding flash messages

There are many syntax variations for adding flash messages, so you can choose the one you like the most.

Let's take a look at some of them.

message() method creates and returns fresh FlashMessage instance which can be modified by chaining methods (all methods could be found in the FlashMessage methods section).

Laraflash facade can be replaced with the laraflash() helper as you could saw in the example above.

message() method accepts up to five arguments: $content, $title, $type, $delay, $hops.

Arguments mentioned in the previous example can be passed directly to the laraflash() helper.

Rendering flash messages

Ready flash messages could be rendered using the render() method of the Laraflash instance.

All methods of the Laraflash instance (which could be obtained by calling laraflash() helper without arguments being passed) could be found in the Laraflash methods section.

Output HTML will be generated using skin, specified in the laraflash.skin config. All available skins are listed in the config file.

Default separator between the messages is the <br>, which is specified in the laraflash.separator config. Feel free to change it if you need.

Example of messages rendered as HTML:

Obtaining flash messages as an array

Flash messages can be obtained as an array using the toArray() method.

Here is the result:

You can use array representation of flash messages for your API.

Laraflash methods

message(?string $content = null, ?string $title = null, ?string $type = null, ?int $delay = null, ?int $hops = null): FlashMessage

Creates and returns fresh FlashMessage instance.

render()

Renders ready flash messages as HTML.

keep(): self

Adds one more hop to each flash message.

clear(): self

Deletes all flash messages.

all(): Collection

Returns the Collection instance containing all flash messages.

ready(): Collection

Returns the Collection instance containing ready flash messages.

touch(): self

Touches all flash messages (decrements amount of hops and delay, deletes expired messages).

toArray()

Returns an array representation of ready flash messages.

toJson()

Returns JSON representation of ready flash messages.

FlashMessage methods

content(?string $content): self

Sets the content of the flash message.

title(?string $title): self

Sets the title of the flash message.

type(?string $type): self

Sets the type of the flash message.

danger(): self

Sets the danger type for the flash message.

warning(): self

Sets the warning type for the flash message.

info(): self

Sets the info type for the flash message.

success(): self

Sets the success type for the flash message.

hops(int $hops): self

Sets the hops amount of the message (the number of requests in which the message will be present).

Default: 1

delay(int $delay): self

Sets the delay of the message (the number of requests in which the message will be waiting to receive the ready state).

Default: 1

now(): self

Shortcut for ->delay(0)

keep(): self

Increments the amount of hops.

attribute(string $key, $value = null): self

Sets the custom attribute which will be present in the array representation of the message and could be obtained using the get() method.

get(string $key)

Returns the value of the attribute.

toArray()

Returns an array representation of the message.

toJson()

Returns JSON representation of the message.

Testing

You can run the tests with:

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

📖 License

Larflash is open-sourced software licensed under the MIT license.


All versions of laraflash with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
laravel/framework Version ^10.0
ext-json Version *
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 coderello/laraflash contains the following files

Loading the files please wait ....