Download the PHP package justinvoelker/yii2-bootstrapnotifyalert without Composer

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

Bootstrap Notify Alerts for Yii2

Bootstrap Notify flash messages for Yii2.

This extension is nothing more than the Bootstrap Notify javascript and the Animate.css styles wrapped in a tiny extension. This extension aims to bring the power of Bootstrap Notify to Yii2 without additional enhancements or overhead. Simply add use justinvoelker\bootstrapnotifyalert\FlashAlert; to your layout and call the widget with <?= FlashAlert::widget() ?> to get started. Of course, there are options that can be specified as well to tweak the settings as desired.

Installation

The preferred way to install this extension is through composer.

Either run

or add

to the require section of your composer.json file.

Setup

Add justinvoelker\bootstrapnotifyalert\BootstrapNotifyAlertAsset as a dependency in your assets\AppAsset file. It should look similar to the following:

Usage

Basic Usage

Simply add the necessary use justinvoelker\bootstrapnotifyalert\FlashAlert; statement to your layout file then call the widget:

Advanced Usage

Rather than accept the defaults specified by Bootstrap Notify, any property can be set through the widget. Here are just a few of the usual options I like to use:

If a single message is needed without using flash data, just specify the message and optional type (type will be 'info' if not specified):

Perhaps there is a very specific need to echo FlashAlert::widget() multiple times but each will have the same options. Use the registerAsDefaults parameter to set the notify options without a message or flash data:

When setting registerAsDefaults to true, be sure to always include <?= FlashAlert::widget() ?> afterward or there will be no alerts, just default options.

Really Advanced Usage

Using the registerAsDefaults above really comes in handy when you need to trigger alerts from multiple places but only want to set the defaults once. For example, most alerts are triggers by setting flash messages inside a controller. However, alerts can also be trigger directly via JavaScript in a view. By default, all of the assets in Bootstrap Notify Alerts are loaded after page ready. This works for alerts set in the controller but is too late for alerts inside some custom, page-specific JavaScript. Using the registerPosition parameter allows us to dictate where the Flash Alert logic is inserted into the page.

A practical example of this is as follows. Nearly every page on a website only displays alerts that were set inside a controller and can load after the page is ready. However, one page of the website needs to set some alerts in some custom JavaScript in the view. On that one page we need the assets and Flash Alert defaults to be registered earlier so that the are available for use later in the page inside the custom JavaScript. To have our normal pages load everything at the end but still be able to user them earlier on some pages we can do the following.

In the view reguiring early registration, set a parameter that can be read from the layout (this can go right below the title and breadcrumb declarations):

Then, in the main layout, register the assets only if that parameter is set (this needs to go before the call to beginPage()):

Finally, also on the main layout, set the registerPosition of the FlashAlert widget that is also setting registerAsDefaults:

Together, the previous snippets of code will set a custom parameter inside a view which will be used inside the layout to register the BootstrapNotifyAlertAsset in the head rather than document ready position. Finally, the FlashAlert sets defaults and will do so at the beginning of the body rather than the document ready position. The last FlashAlert::widget() will display all alerts set within a controller. At this point, everything will work the same except in the view we can add $.notify('User invited',{ type: 'success' }); and have an alert display without reloading the page.

Optional

Additional CSS can be specified in your site stylesheet to further define the look and feel of the alerts. To use either of the following progressbar styles, the showProgressbar option needs to be set to true.

The Bootstrap Notify documentation includes a specific example to change the size and position of the progress bars to match their appearance in the demos:

Another style that I frequently use adjusts the progress bar so that is has a smooth continuous animation rather than start-stop movements:


All versions of yii2-bootstrapnotifyalert with dependencies

PHP Build Version
Package Version
Requires yiisoft/yii2 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 justinvoelker/yii2-bootstrapnotifyalert contains the following files

Loading the files please wait ....