2017 © Pedro Peláez
 

library php-livereload

a livereload server implement by php

image

rickysu/php-livereload

a livereload server implement by php

  • Monday, January 16, 2017
  • by rickysu
  • Repository
  • 1 Watchers
  • 69 Stars
  • 2,674 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 9 Forks
  • 2 Open issues
  • 4 Versions
  • 4 % Grown

The README.md

PHP Livereload

Build Status Coverage Status, (*1)

php-livereload is a livereload server written in PHP., (*2)

php-livereload uses livereload.js -- a JavaScript file implementing the client side of the LiveReload protocol., (*3)

Install

Install php-livereload from composer., (*4)

{
    "require": {
        "rickysu/php-livereload": "dev-master"
    }
}

Get the command-line php-livereload, (*5)

$ curl -O https://raw.github.com/RickySu/php-livereload/master/dist/reload.phar
$ chmod +x reload.phar
$ sudo mv reload.phar /usr/bin

Install LiveReload Safari/Chrome/Firefox extension, (*6)

Tests

To run the test suite, you need install the dependencies via composer, then run PHPUnit., (*7)

$ composer install
$ phpunit

Using php-livereload

define a livereload.json in your project root., (*8)

livereload.json, (*9)

{
    "period": 1,
    "watch": {
        "web/css/":   "*.css",
        "web/js/":    "*.js",
        "web/img/":   "\\.png|gif|jpg$"
    }
}
  • period: monitor file changes every 1 second.
  • watch: file and folder you want to watch

Initialize a default livereload.json file.

$ php bin/reload livereload:init

Running Server.

$ php bin/reload server:run

Rolling Your Own Live Reload

If you would like to trigger the live reload server yourself, simply POST files to the URL: http://localhost:35729/changed. Or if you rather roll your own live reload implementation use the following example:, (*10)

# notify a single change
curl http://localhost:35729/changed?files=style.css

# notify using a longer path
curl http://localhost:35729/changed?files=js/app.js

# notify multiple changes, comma or space delimited
curl http://localhost:35729/changed?files=index.html,style.css,docs/docco.css

Or you can bulk the information into a POST request, with body as a JSON array of files., (*11)

curl -X POST http://localhost:35729/changed -d '{ "files": ["style.css", "app.js"] }'

# from a JSON file
node -pe 'JSON.stringify({ files: ["some.css", "files.css"] })' > files.json
curl -X POST -d @files.json http://localhost:35729

License

MIT, see LICENSE., (*12)

The Versions

16/01 2017

dev-master

9999999-dev

a livereload server implement by php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ricky Su

16/01 2017

v0.1.2

0.1.2.0

a livereload server implement by php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ricky Su

06/04 2016

v0.1.1

0.1.1.0

a livereload server implement by php

  Sources   Download

MIT

The Requires

 

The Development Requires

by Ricky Su

05/03 2015

v0.1.0

0.1.0.0

a livereload server implement by php

  Sources   Download

MIT

The Requires

 

by Ricky Su