-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Henrik Bjornskov
committed
Oct 27, 2015
1 parent
550d936
commit 2aa0763
Showing
3 changed files
with
53 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,8 @@ | ||
Lurker | ||
====== | ||
|
||
This is a continuation of Konstantin Kudryashov's ResourceWatcher for Symfony2. It have been moved | ||
from his fork and renamed Lurker to allow a wider adoption. | ||
Resource tracking for PHP. Watch files and/or directories. For more information | ||
[look at the documentation here](http://lurker.rtfd.org). | ||
|
||
[![Build Status](https://travis-ci.org/henrikbjorn/Lurker.png?branch=master)](https://travis-ci.org/henrikbjorn/Lurker) | ||
|
||
Getting Started | ||
--------------- | ||
|
||
Use composer to install it by adding the following to your `composer.json` file. | ||
|
||
``` json | ||
{ | ||
"require" : { | ||
"henrikbjorn/lurker" : "1.0.*@dev" | ||
} | ||
} | ||
``` | ||
|
||
And then run `composer update henrikbjorn/lurker` to get the package installed. | ||
|
||
### Tracking Resources | ||
|
||
Lurker works by giving the resource watcher a tracking id which is the name of the event and a path to | ||
the resource you want to track. | ||
|
||
When all the resources have been added that should be track you would want to add event listeners for them so | ||
your can act when the resources are changed. | ||
|
||
``` php | ||
<?php | ||
|
||
use Lurker\Event\FilesystemEvent; | ||
use Lurker\ResourceWatcher; | ||
|
||
$watcher = new ResourceWatcher; | ||
$watcher->track('twig.templates', '/path/to/views'); | ||
|
||
$watcher->addListener('twig.templates', function (FilesystemEvent $event) { | ||
echo $event->getResource() . 'was' . $event->getTypeString(); | ||
}); | ||
|
||
$watcher->start(); | ||
``` | ||
|
||
The above example would watch for all events `create`, `delete` and `modify`. This can be controlled by passing a | ||
third parameter to `track()`. | ||
|
||
``` php | ||
<?php | ||
|
||
$watcher->track('twig.templates', '/path/to/views', FilesystemEvent::CREATE); | ||
$watcher->track('twig.templates', '/path/to/views', FilesystemEvent::MODIFY); | ||
$watcher->track('twig.templates', '/path/to/views', FilesystemEvent::DELETE); | ||
$watcher->track('twig.templates', '/path/to/views', FilesystemEvent::ALL); | ||
``` | ||
|
||
Note that `FilesystemEvent::ALL` is a special case and of course means it will watch for every type of event. | ||
|
||
Special Thanks | ||
-------------- | ||
|
||
* [Konstantin Kudryashov](http://twitter.com/everzet) for the original code. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
Getting Started | ||
=============== | ||
|
||
Use composer to install it by adding the following to your `composer.json` file. | ||
|
||
``` bash | ||
composer require henrikbjorn/lurker | ||
``` | ||
|
||
And then run `composer update henrikbjorn/lurker` to get the package installed. | ||
|
||
Tracking Resources | ||
------------------ | ||
|
||
Lurker works by giving the resource watcher a tracking id which is the name of the event and a path to | ||
the resource you want to track. | ||
|
||
When all the resources have been added that should be track you would want to add event listeners for them so | ||
your can act when the resources are changed. | ||
|
||
``` php | ||
<?php | ||
|
||
use Lurker\Event\FilesystemEvent; | ||
use Lurker\ResourceWatcher; | ||
|
||
$watcher = new ResourceWatcher; | ||
$watcher->track('twig.templates', '/path/to/views'); | ||
|
||
$watcher->addListener('twig.templates', function (FilesystemEvent $event) { | ||
echo $event->getResource() . 'was' . $event->getTypeString(); | ||
}); | ||
|
||
$watcher->start(); | ||
``` | ||
|
||
The above example would watch for all events `create`, `delete` and `modify`. This can be controlled by passing a | ||
third parameter to `track()`. | ||
|
||
``` php | ||
<?php | ||
|
||
$watcher->track('twig.templates', '/path/to/views', FilesystemEvent::CREATE); | ||
$watcher->track('twig.templates', '/path/to/views', FilesystemEvent::MODIFY); | ||
$watcher->track('twig.templates', '/path/to/views', FilesystemEvent::DELETE); | ||
$watcher->track('twig.templates', '/path/to/views', FilesystemEvent::ALL); | ||
``` | ||
|
||
Note that `FilesystemEvent::ALL` is a special case and of course means it will watch for every type of event. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
site_name: Lurker | ||
theme: readthedocs |