Download the PHP package lacodix/laravel-notification-subscriptions without Composer

On this page you can find all versions of the php package lacodix/laravel-notification-subscriptions. 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 laravel-notification-subscriptions

Laravel Notification Subscriptions

Manage per-recipient notification preferences in Laravel: subscribe or unsubscribe by channel, require opt-in, and scope preferences to another Eloquent model. The package filters Laravel's normal notification sending flow; it does not provide a settings UI.

Latest Stable Version Total Downloads License

A fork of liran-co/laravel-notification-subscriptions, originally authored by Liran Cohen and maintained by Lacodix. Original author and MIT attribution are retained. The package name is lacodix/laravel-notification-subscriptions, and its public namespace is Lacodix\LaravelNotificationSubscriptions.

Requirements and installation

Requires PHP ^8.2 (>=8.2 and <9) and Laravel ^11.0|^12.0|^13.0. Laravel 13 requires PHP >=8.3. Laravel 11 compatibility does not imply current security support; use a maintained Laravel version for production. Older environments need a compatible prior package version.

Laravel auto-discovers the package provider. The migration creates the notification_subscriptions table. To optionally publish config/notification-subscriptions.php, select the provider explicitly:

Enable preferences on your user model

Add both Laravel's Notifiable and the package's HasNotificationSubscriptions traits to your Eloquent notifiable model. Keep your existing model configuration; this is a minimal example:

Notifiables without HasNotificationSubscriptions are not filtered by this package. Configure your delivery channels using Laravel's notification documentation.

Subscribe, unsubscribe and reset

Pass the notification's exact class name. Examples below use your application's App\Notifications\InvoicePaid; a complete illustrative implementation appears in Model scoping. Lookup IDs are examples for existing application records.

An exact channel rule takes priority over '*'. Changing a wildcard does not remove channel-specific rules: in this example, the final wildcard subscription still leaves mail unsubscribed. Subscribe/unsubscribe reuse an existing exact rule instead of creating a new row each time.

Reset removes the requested notification's rules in the selected scope and returns the notifiable, so calls can be chained:

Without a model argument, reset removes only global rules; scoped rules remain. Without a matching preference, delivery is allowed unless the channel is opt-in.

Model scoping

A scope lets a recipient keep different preferences for individual organizations, invoices or other Eloquent models. The following illustrative notification uses your application's persisted App\Models\Organization model. Replace the message and channel implementation with your application's requirements:

getSubscriptionModel($notifiable) returns the Eloquent model to use as a scope, or null for global preferences. Rules store the concrete get_class($model) and its id property (optional($model)->id), not a morph alias or custom primary key returned by getKey().

The scoped reset removes only that model's rules. Global rules and other scopes remain; global preferences become the fallback for this scope.

Opt-in channels

Laravel's normal notify() and Notification::send() flow reads getOptInSubscriptions() with no arguments. It must return the channels that need an explicit matching subscription. In the illustrative notification above, the constructor's optIn array supplies that list:

A matching wildcard or global subscription can also satisfy opt-in according to the precedence below. Direct isSubscribed() checks require you to pass the opt-in list explicitly; they do not construct a notification or call its methods.

Preference precedence

For each recipient, notification class and channel, the first matching rule wins:

  1. Scoped exact channel.
  2. Scoped wildcard ('*').
  3. Global exact channel.
  4. Global wildcard ('*').
  5. No rule: allow, unless the channel is opt-in.

Unscoped notifications start at the global rules. A global unsubscribe suppresses scoped notifications when no scoped rule exists; an explicit scoped subscription can override it. A global subscription can satisfy an opt-in channel. Rules for other recipients, notification types or model scopes are never used as fallback.

Use exact stored notification, channel and scope-class names matching the notification class, via() channel values and get_class($model). Hand-written values that depend on database collation (such as different case or trailing spaces) are not guaranteed equivalent between SQL and loaded-collection matching.

Read preferences and eager-load

For multiple recipients, eager-load the complete relation:

Loaded findSubscription() and isSubscribed() reads perform no additional SQL, including misses and empty collections. Unloaded reads query the requested rules without loading the whole relation.

Prefer subscribe/unsubscribe for preference changes. createSubscription() is a direct row creation API, not an upsert.

Bypass filtering and observe suppression

The default excluded channel is database. Change config/notification-subscriptions.php if needed:

Or bypass subscription checks for a notification using its declared public ignoreSubscriptions property. The example class above exposes it as a constructor argument:

Excluded channels and ignoreSubscriptions skip only this package's filtering. Other application event listeners can still veto delivery. isSubscribed() itself checks preferences; these bypasses belong to the sending listener.

When this package vetoes a channel, it emits NotificationSuppressed. Register a listener in your application's service provider boot() method, for example:

The event exposes notifiable, notification, channel and the original Laravel NotificationSending event as event. Application-listener vetoes alone do not emit this package event.

Upgrading

When migrating from upstream, remove liran-co/laravel-notification-subscriptions and install lacodix/laravel-notification-subscriptions. Replace imports and manual provider references from LiranCo\NotificationSubscriptions to Lacodix\LaravelNotificationSubscriptions. There are no compatibility aliases or Composer replace declaration for upstream; stored rows, schema and configuration stay unchanged. Clear or rebuild Laravel's event cache after changing provider references:

When updating an existing Lacodix installation, check the current PHP/Laravel requirements above. Global preferences now act as fallback for scoped notifications in both directions: existing unsubscribes may suppress delivery, and subscriptions may satisfy opt-in. Add an explicit scoped rule to keep a model-specific exception. No schema or data migration is required for this preference-resolution change.

Contributing

From a checkout with the required PHP extensions and Composer:

Tests use Testbench, in-memory SQLite, the package provider/migrations and Laravel's real notification sender with a local recording channel. Quality runs PHP CS Fixer and Larastan. No development lock file is committed.

The 22-lane compatibility matrix covers:

Laravel Testbench PHP Dependency selection
11 9 8.2, 8.3, 8.4, 8.5 prefer-stable and prefer-lowest
12 10 8.2, 8.3, 8.4, 8.5 prefer-stable and prefer-lowest
13 11 8.3, 8.4, 8.5 prefer-stable and prefer-lowest

Lowest means the lowest resolvable stable dependencies under the development constraints and Composer's security policy, not necessarily a framework's initial .0 version. Laravel 11 tests have explicit advisory exceptions in the isolated CI lane helper; they do not weaken the package manifest or imply Laravel 11 security support.

Useful source and test entry points:

Area Source
Preference reads/writes and cache handling HasNotificationSubscriptions
Stored rules and exact model scope NotificationSubscription
Sending veto/bypass and suppression fields event
Config, migration and listener registration migrations
Precedence, isolation, mutations and real sending fixtures

Preserve exact-scope writes, recipient/type isolation, channel/scoped/global precedence, zero-query complete loaded reads and fresh mutation lookup. Sending suppression returns false; allowed/bypassed notifications abstain (null) so other application listeners can run and veto. Cover behavior changes through the real sender as well as direct preference checks.

License

MIT.


All versions of laravel-notification-subscriptions with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
laravel/framework Version ^11.0|^12.0|^13.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 lacodix/laravel-notification-subscriptions contains the following files

Loading the files please wait ...