PHP Classes

File: example/example.php

Recommend this page to a friend!
  Classes of Kacper Rowinski   PHP iNotify Extension Class   example/example.php   Download  
File: example/example.php
Role: Example script
Content type: text/plain
Description: Class source
Class: PHP iNotify Extension Class
Get notifications of when directory files change
Author: By
Last change:
Date: 5 years ago
Size: 1,015 bytes
 

Contents

Class file image Download
<?php


use Inotify\InotifyConsumerFactory;
use
Inotify\InotifyEvent;
use
Inotify\InotifyEventCodeEnum;
use
Inotify\WatchedResourceCollection;
use
Symfony\Component\EventDispatcher\EventSubscriberInterface;

include
__DIR__ . '/../vendor/autoload.php';

$inotifyConsumerFactory = new InotifyConsumerFactory();
$inotifyConsumerFactory->registerSubscriber(
    new class implements
EventSubscriberInterface
   
{
        public static function
getSubscribedEvents(): array
        {
            return [
InotifyEvent::class => 'onInotifyEvent'];
        }

        public function
onInotifyEvent(InotifyEvent $event): void
       
{
            echo
$event;
        }
    }
);
$inotifyConsumerFactory->consume(
   
WatchedResourceCollection::createSingle(
       
sys_get_temp_dir(),
       
// sys_get_temp_dir() . '/test.log',
        //InotifyEventCodeEnum::ON_CREATE()->getValue() | InotifyEventCodeEnum::ON_DELETE()->getValue(),
       
InotifyEventCodeEnum::ON_ALL_EVENTS()->getValue(),
       
'test'
   
)
);