Download the PHP package hackeresq/laravel-watcher without Composer

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

laravel-watcher

Latest Version on Packagist Total Downloads

Set a watcher to watch for specific keys in your Laravel form requests. If those keys are present, perform any arbitrary functions(s).

Installation

This package can be used in Laravel 5.4 or higher.

You can install the package via composer:

Watcher is a trait that can be added to your Laravel FormRequests (or you can use the included base FormRequest). To start using the setWatcher() method, you must 'use' the Watcher trait by either adding it to your FormRequest or using the base WatcherRequest in your controllers.

An example of a custom FormRequest implementation:

Alternatively, if you are not using custom FormRequests, you can use the provided WatcherRequest, which already has the trait added. This is how your controller methods should look:

Success! laravel-watcher is now installed!

Usage

Once you've added the trait to your custom FormRequest or you've added the WatcherRequest to your controller method, you'll have a new setWatcher() method available on your requests. This allows you to set up your watcher.

Basic Usage

The basic usage of the setWatcher() method is to pass an array, with the "trigger" as the key, like so:

You will notice that the key is the "watched" trigger. If the 'invoice_start_num_changed' is present (and not falsey) the defined 'action,' which is an anonymous function, will be called.

Remove Key

You can optionally choose to remove the trigger from the request (e.g. if you are passing the request elsewhere and want to sanitize it) by passing a 'removeKey' attribute, like this:

Passing Context

You will notice you can pass $context to the anonymous function. This $context object contains the trigger name (in the $context->trigger object) and the original form request (in the $context->request object).

Trigger even when request is empty

Finally, if you want the action to fire even when the trigger is null or empty, you can use the allowEmpty option. Just set allowEmpty to true when you configure your triggers:

Call multiple functions

If you do not want to create and call an intermediary function, and would prefer to call multiple functions from within the watcher, you can opt to use a standard anonymous function (rather than the short arrow function), like this:

Complete Example

SettingsController.php

Finally

Testing

You can run tests with the composer test command.

Contributing

Feel free to create a fork and submit a pull request if you would like to contribute.

Bug reports

Raise an issue on GitHub if you notice something broken.


All versions of laravel-watcher with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
laravel/framework Version ^6.0|^7.0|^8.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 hackeresq/laravel-watcher contains the following files

Loading the files please wait ....