Download the PHP package michaeljennings/feed without Composer

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

Feed (deprecated for Laravel 5.3+) Build Status Coverage Status

Note: This package is no longer maintaned for Laravel 5.3+ since Laravel now offers built in notifications.

A basic notification feed for laravel 5+.

Below is some example code of all of the basic methods for the package.

Navigation

Installation

This package requires at least laravel 5.

To install through composer include the package in your composer.json.

"michaeljennings/feed": "0.2.*"

Run composer install or composer update to download the dependencies, or you can run composer require michaeljennings/feed.

Once installed add the service provider to the providers array in config/app.php.

To publish the migrations and config files run php artisan vendor:publish.

Configuration

The package comes with a default migration to create the database structure for the package. By default this table allows for the notifications to have a body, and an icon. If need more data for your notification such as a title, we recommend adding the columns to the default migration.

The package comes with feed.php config file. This allows you to customise the database driver you are using with the package. At present only eloquent is supported, but we are working on a laravel db driver currently.

Changing the Notification Model

From time to time you may need to add additional methods or properties to the notification model, for example you might want to add an additional relationship to the notification model.

This can be done very simply by changing the notification model in the config file as shown below.

The default notification model implements a couple of interfaces that are required by this package. If you need to make changes to the model I recommend extending the default model, otherwise make sure you implement the interfaces.

Adding a Driver

You may require another driver, i.e. you're using a data store not supported by laravel. If this is the case you can add a driver to the system verify simply as shown below.

For more information on adding drivers look at the laravel documentation on extending the framework.

Using the Feed

Once installed you can access the feed in multiple ways.

Firstly you can dependency inject it from the IOC container by either the push or pull feed interfaces. Both interfaces will return the same instance, it's just to make your code more readable.

Or you there is a feed helper method.

Or if you want to use the facade you can register it in the aliases array in config/app.php.

Setting Up Notifiable Models

To set up a notifiable model you just need to implement the notifiable interface, and then use the notifiable trait in your model.

This will set up the required relationships.

Notifiable Groups

It is also possible to set up groups of notifiable models, an example of when this would be useful is having a team of users. This will allow us to push a notification to all the members of that group.

To set up a notifiable group you need implement the notifiable group interface on the group model. This will add a method called getGroup which requires you to return the members you would like to be notified.

In the example below we have a team model which implements the group interface. It has a users relationship which returns all of the users belonging to the team. Then in the getGroup method we simply return the users.

Available Methods

Below is a list of all of the currently available notification methods. If you think of anything you want to add please feel free to create an issue, or a pull request.

Push

The push method allows you to push a notification to a notifiable model, multiple notifiable models, or a notifiable group.

When pushing to a notifiable group each member of the group will get their own notification, it will not share one notification for all of the members.

When the notification is pushed a NotificationAdded event will be fired.

You can then listen for this and then broadcast the notification, send an email etc.

You just need to register the listeners in the event service provider.

Pull

The pull method gets all of the unread notifications for the notifiable models you pass it.

Pull Read

To get all of the read notifications for a member, use the pullRead method.

Limiting Results

To limit the amount of notifications returned when pulling, chain the limit method.

Offsetting Results

To offset the results when pulling, chain the offset method. This can be useful for infinte scrollers.

Paginate Results

If you want to paginate the results and let laravel handle the limiting and offsetting for you, chain the paginate method.

Filtering Results

From time to time you may wish to run additional queries on the notification results, to do this chain the filter method.

The filter method requires a closure which is passed an instance of the query builder. In the example below we're only getting results that have an alert icon.

Get the Latest Results

To order the results by the latest notification added, chain the latest method. By default the notifications are ordered by the latest notification added.

Get the Oldest Results

To order the results by the oldest notification added, chain the oldest method. By default the notifications are ordered by the latest notification added.

Putting it All Together

All of these methods can be chained together, this should allow you to get the notifications in any way you require.

Marking Notification as Read

To mark a notification as read you can either use the markAsRead method, or it is aliased to read if you prefer.

When the notification is read marked as read a NotificationRead event will be fired.

You can then listen for this and then broadcast it etc.

Marking Notification as Unread

To mark a notification as unread you can either use the markAsUnread method, or it is aliased to unread if you prefer.

When the notification is read marked as unread a NotificationUnread event will be fired.

You can then listen for this and then broadcast it etc.


All versions of feed with dependencies

PHP Build Version
Package Version
Requires illuminate/database Version 5.*
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 michaeljennings/feed contains the following files

Loading the files please wait ....