Download the PHP package splitstack/laravel-nudge without Composer

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

Laravel Nudge

Tests PHP Version Laravel Version Total Downloads

Give notifications a lifecycle. A notification declares the action it is waiting on; when that action runs anywhere in your application, the notification resolves itself — no manual wiring required.

→ See it in action

Installation

Publish and run the migration:

The migration adds a resolved_at column to your notifications table. If the table does not exist yet, it creates it.

Concept

A notification is not just a message — it is a pending state tied to an expected future action.

The controller, the webhook handler, and the notification have no knowledge of each other.

Actions

There are two ways to make an action class resolvable, depending on whether it already exists or is being written from scratch.


New action classes — extend NudgeAction

If you are writing an action class from scratch, extend NudgeAction. Implement your logic in a protected nudge() method (convention) or in any method marked #[Nudge] (for a custom name). The handle() entry point, event dispatch, and resolution are all handled for you.

If you prefer a different method name, mark it with #[Nudge]:

Call sites — pick whichever style fits your codebase:


Existing action classes — use the trait

If you have an action class that already exists and already has its own call sites, you do not need to rewrite call sites. (You're free to do so if you want, of course. In that case refer to the "New action classes" section above)

Implement ResolvableAction, add the DispatchesActionExecuted trait, and drop $this->nudge($params) at the point in your method where the action completes. Your call site stays exactly as it was.


You can also dispatch the event manually as an escape hatch — useful for actions you don't own:

Notifications

Extend ActionableNotification and supply the action key either via forAction() at call site or by overriding useActionKey() on the class.

Option A — forAction() at call site (action key decided by the caller):

Option B — useActionKey() on the class (action key baked into the notification):

withData() is optional — omit it if your notification needs no payload beyond the action metadata. If both useActionKey() and forAction() are used, useActionKey() takes precedence.

Param matching

The stored params are matched as a subset of the executed params. This means:

Extra keys in the executed params are ignored. Store only the params that must match.

Deep matching

By default matching is shallow — only top-level keys are compared. Set match_params to 'deep' in config/nudge.php to enable recursive subset matching, useful when your action params contain nested arrays:

Matching is strict (===) at every level regardless of mode, so '5' and 5 are not considered equal.

Querying

Add HasResolvableNotifications to your notifiable model for convenience scopes:

Or query directly on DatabaseNotification:

Migrating an existing notification class

If you already have a notification with a toDatabase() method and you swap extends Notification for extends ActionableNotification, do not keep the toDatabase() override. ActionableNotification::toDatabase() is what injects _action_key and _action_params into the stored payload — overriding it silently strips that metadata and the notification will never resolve.

Replace toDatabase() with withData() instead:

withData() is merged into the final payload by the parent; your data and the action metadata both end up in the database.

Upgrading from < 0.6.0

The old execute() entry point and the requirement to name your handler handle() have been removed in favour of the two-path API above. execute() still works but emits E_USER_DEPRECATED — follow the deprecation message to migrate at your own pace.

Caveats

Avoid sending notifications inside controller methods that can be hit multiple times

Some middleware or frontend patterns cause controller methods to be invoked more than once per user interaction. A well-known case is Inertia.js deferred props: a HandleInertiaRequests middleware that uses Inertia::defer() triggers a second request to the same route, calling the controller twice. If $user->notify(...) is in that controller, the same notification gets stored twice.

The safer placement is inside a dedicated action, a queued job, an observer, or a service — anywhere outside the HTTP layer that can be hit multiple times.

Requirements


All versions of laravel-nudge with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/database Version ^11.0|^12.0|^13.0
illuminate/events Version ^11.0|^12.0|^13.0
illuminate/notifications Version ^11.0|^12.0|^13.0
illuminate/support 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 splitstack/laravel-nudge contains the following files

Loading the files please wait ...