Skip to content

Commit

Permalink
add Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrik Bjornskov committed Oct 27, 2015
1 parent 550d936 commit 2aa0763
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 59 deletions.
61 changes: 2 additions & 59 deletions README.md
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.
49 changes: 49 additions & 0 deletions docs/index.md
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.
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
site_name: Lurker
theme: readthedocs

0 comments on commit 2aa0763

Please sign in to comment.