hnhdigital-os/laravel-folder-watcher

Provides a Laravel console command that can watch a given folder, and any changes are passed to the provided command script.
137 8
Install
composer require hnhdigital-os/laravel-folder-watcher
PHP:>=5.6.0
License:MIT
Last Updated:Feb 5, 2019
Links: GitHub  ·  Packagist
Maintainer: bluora

Laravel Folder Watcher

Provides a Laravel console command that can watch a given folder, and any changes are passed to the provided command script.

Useful for running as a background task that initiates a virus scan on uploaded files.

Checkout our standalone command line tool inspired by the work we did here. github.com/hnhdigital-os/fs-watcher.

Latest Stable Version Total Downloads Latest Unstable Version License

Build Status StyleCI Test Coverage Issue Count Code Climate

This package has been developed by H&H|Digital, an Australian botique developer. Visit us at hnh.digital.

Install

Via composer:

$ composer require-dev hnhdigital-os/laravel-folder-watcher dev-master

Enable the console command by editing app/Console/Kernel.php:

    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
      ...
      Bluora\LaravelFolderWatcher\FolderWatcherCommand::class,
      ...
    ];

Usage

Run the console command using the following:

Load

Load a given configuration file. This will load a background process for each folder/binary combination.

# php artisan watcher load --config-file=***

Background

Loads a given watch path and binary as a background process.

# php artisan watcher background --watch-path=*** --binary=*** --script-arguments=***

Run

Runs a given watch path and binary.

# php artisan watcher run --watch-path=*** --binary=*** --script-arguments=***

List

Lists all the background watch processes currently active.

# php artisan watcher list

Kill

Provide a process id (from the list action) to stop it running. Using --pid=all will stop all processes.

# php artisan watcher kill --pid=***

Configuration file

You can provide any yaml based file as input to this command using the load action and the --config-file argument.

The yaml file is in the following format:

[folder path]:
    - [binary]: [arguments]
  • [folder path]: The directory that will be watched for changes. The watcher recursively adds all child folders.
  • [binary]: The binary that we will run. This could be an absolute path or an alias. (eg php)
  • [arguments]: The arguments that need to be given to the binary. Use the placeholders below to allow the watcher to pass this through.

Command placeholders

  • {{file-path}}: The absolute file path to the changed file.
  • {{root-path}}: The base directory of the watcher.
  • {{file-removed}}: Boolean (1 or 0) to indicate if the file was deleted.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

Related Packages

syamsoul/laravel-action-delay

Delay a Job, Database Query or PHP code at a specific datetime easily with one s...

171 1
jaybizzle/laravel-migrations-organiser

A Laravel package to help organise migration files.

415,783 112
alejojperez/laravel-skeleton-generator

A package containing a set of commands to generate any kind of component

22 1
nwidart/db-exporter-l4.0

Export your database quickly and easely as a Laravel Migration and all the data...

15 5