GithubHelp home page GithubHelp logo

basirsharif / php-file-watcher Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thecodeholic/php-file-watcher

0.0 1.0 0.0 10 KB

Watch file or folder and execute code when something is changes inside

PHP 100.00%

php-file-watcher's Introduction

php-file-watcher

Watch file or folder and execute code when something is changed inside

Demo

You can run the following command to see how the script works

php index.php FILE_OR_FOLDER_PATH

Basic usage

$watcher = new \tc\fswatcher\Watcher('FILE_OR_FOLDER_PATH_TO_WATCH', function ($event) {
    // Do whatever you want when file or folder is changed.
    if ($event->isAddition()){
        // File was added and file path will be $event->file
    } else if ($event->isModification()){
        // File was modified and file path will be $event->file
    }
});
$watcher->watch();

Advanced Usage

$watcher = new \tc\fswatcher\Watcher('FILE_OR_FOLDER_PATH_TO_WATCH', 'callback', [
    'watchInterval' => 5,
    'cacheChanges' => true
]);

Options

Option Default value Description
watchInterval 1 How often the file changes should be checked
cacheChanges true Gather file modifications in single check and trigger event once

php-file-watcher's People

Contributors

thecodeholic avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.