Download the PHP package hampel/alerts without Composer

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

Alerts for Laravel

Latest Version on Packagist Total Downloads Open Issues License

This package provides session-driven alerts for Laravel and provides alert templates for both Bootstrap and Foundation based front-end frameworks.

By Simon Hampel

Installation

To install through composer, run the following command:

composer require hampel/alerts

If you want to change the default Alert configuration or views, first publish them using the command:

The config file can then be found in config/alerts.php, and the views in resources/views/vendor/alerts

Usage

The alerts functionality is based around two classes - the first is an AlertManager class, which you can access in your code via the Alert facade (or via the container $app['alerts']). The AlertManager class uses a Laravel MessageBag to store alert a collection of alerts, grouped by alert key (warning, error, success, etc).

Once you have finished adding alerts, you can then "flash" them to the session so that the alert messages are then available after a page redirect.

At this point, the second part of the functionality comes into play. The package provides a view composer, which waits for a particular view to be rendered and then executes, injecting the stored alert information which is retrieved from the session. The alerts are essentially rendered as a series of sub-views which are inserted into the base view using a configurable variable.

We can easily add alerts to the AlertManager using the built-in functionality:

There are four alert levels provided by default: info, warning, error, success. Note that any alert level passed to the add function which is not in the configured list of alert levels, will be ignored when rendering the view.

You can add a message to the AlertManager using a shorthand function corresponding to the configured alert levels:

If you prefer to use the language translation files for your messages, you can simply specify a translation key and the AlertManager will substitute the corresponding language entry and optionally apply any replacements too. Note that this only works if you use the shorthand functions to add your messages.

Alternatively, you could apply the translation yourself:

You can retrieve the underlying MessageBag implementation and merge an existing MessageBag.

To pass the alert messages to a view response, you will need to flash the data to the session.

You can do this in several ways - the AlertManager class provides a flash function, which sets the session key for you automatically, or you could do it as part of a redirect response. If not using the built-in flash function, make sure you specify the name of the session key used in the config file 'alerts::session_key', or use the helper function Alerts::getSessionKey():

The package provides a view composer which automatically renders alerts whenever the view is called. There are several ways to do this.

By default, there is a Blade template alerts.blade.php which you can include in your base view. The view composer is configured by default to watch this view and render the alerts whenever this view is rendered. To use, simply @include the template in your view:

If you prefer to do it yourself, you can change the configuration of the view composer to watch a different view, perhaps even your layouts.base view. The composer will generate the alert data and bind it to the configured variable name, which you can then simply echo out in your view.

There are templates provided for both Bootstrap and Foundation, although Foundation is the default - you'll need to change the configuration setting if you use Bootstrap. Alternatively, you can provide your own view template to use to render each alert message. Refer to the configuration file for more information on what the settings do.


All versions of alerts with dependencies

PHP Build Version
Package Version
Requires php Version ^7.1.3|^8.0
illuminate/support Version 5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0
illuminate/session Version 5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0
illuminate/translation Version 5.7.*|5.8.*|^6.0|^7.0|^8.0|^9.0|^10.0
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 hampel/alerts contains the following files

Loading the files please wait ....