PHPackages                             elephfront/robo-live-reload - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. elephfront/robo-live-reload

ActiveRobo-tasks[CLI &amp; Console](/categories/cli)

elephfront/robo-live-reload
===========================

Live reload mechanism for the Robo task runner when using it as a template builder

1.0.0(8y ago)01841MITPHPPHP &gt;=7.1.0

Since Aug 9Pushed 8y ago1 watchersCompare

[ Source](https://github.com/elephfront/robo-live-reload)[ Packagist](https://packagist.org/packages/elephfront/robo-live-reload)[ RSS](/packages/elephfront-robo-live-reload/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (1)

Robo Live Reload
================

[](#robo-live-reload)

[![Software License](https://camo.githubusercontent.com/9a66612deb245a997157ce51e09a457827107c9cd9a9ee14c908c16fe9ee6f7f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f6272616e63683d6d6173746572)](LICENSE.txt)[![Build Status](https://camo.githubusercontent.com/0a597e64eef1534f0c39dcf4a50cd84b6647a328eb2534f686b522a6b9084ca0/68747470733a2f2f7472617669732d63692e6f72672f656c65706866726f6e742f726f626f2d6c6976652d72656c6f61642e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/elephfront/robo-live-reload)[![Codecov](https://camo.githubusercontent.com/98a700a5c05893da1fdfd293ff9201b2d98a4532a749e6d598fd1343be93be32/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f656c65706866726f6e742f726f626f2d6c6976652d72656c6f61642e737667)](https://github.com/elephfront/robo-live-reload)

This [Robo](https://github.com/consolidation/robo) task starts a Live Reload server when using Elephfront.

If you use the base Elephfront skeleton, it will be fired up when you start the `serve` command. Whenever you edit a file, it will trigger the related commands and triggers a refresh in the browsers connected to the Elephfront server. For instance, if you edit a SASS file, it will compile the SASS source to CSS, minify the results and automatically trigger a refresh in your browser.

The Live Reload server is powered by compilation using the [ratchetphp/Ratchet](https://github.com/ratchetphp/Ratchet) using a WebSocket server.

You can of course use it outside of an Elephfront project.

Requirements
------------

[](#requirements)

- PHP &gt;= 7.1.0
- Robo

Installation
------------

[](#installation)

You can install this Robo task using [composer](http://getcomposer.org).

The recommended way to install composer packages is:

```
composer require elephfront/robo-live-reload

```

Implementation
--------------

[](#implementation)

In order to work, this task needs two things :

- to launch a Live Reload server : this will be done by the `elephfront-robo-live-reload` file in the `bin` directory
- a javascript file that will connect your page to the Live Reload server and listen to message that will force the browser the reload. You will need to include this file (either manually or automatically) in your HTML pages. If you are using the Elephfront project skeleton, this file will automatically be added by the router at the end of your pages.

Using the task
--------------

[](#using-the-task)

You can load the task in your RoboFile using the `LoadLiveReloadTaskTrait` trait:

```
use Elephfront\RoboLiveReload\Task\Loader\LoadLiveReloadTaskTrait;

class RoboFile extends Tasks
{

    use LoadLiveReloadTaskTrait;

    public function someTask()
    {
        $this
            ->taskLiveReload()
            ->run();
    }
}
```

The `LiveReload` task has some utility methods that will give you the ability to customize the server launched.

### `host()`

[](#host)

Gives you the ability to change the host the server will be hosted on. By default : `127.0.0.1`.

### `port()`

[](#port)

Gives you the ability to change the port the server will be hosted on. By default : `22222`.

### `bin()`

[](#bin)

Gives you the ability to change the bin path where the script that will start the Live Reload server is located. By default : `vendor/bin`.

### `jsPath()`

[](#jspath)

Gives you the ability to change the path where the javascript file needed to make the browser listen to the Live Reload server and force the refresh will be located. By default, it will put it in the expected location of the build directory of an Elephfront project : `build/system/LiveReload/assets/js/livereload.js`. Based on your project setup, you may have to customize this value.

Notifying the LiveReload server
-------------------------------

[](#notifying-the-livereload-server)

To send a message to the Live Reload server so it can propagate it to the browser and the reload triggered, you can use the `sendReloadMessage()` of the task::

```
use Elephfront\RoboLiveReload\Task\Loader\LoadLiveReloadTaskTrait;

class RoboFile extends Tasks
{

    use LoadLiveReloadTaskTrait;

    public function someTask()
    {
        $this
            ->taskLiveReload()
            ->run();

        // Further down...
        $this
            ->taskLiveReload()
            ->sendReloadMessage();
    }
}
```

This will send a "reload" message to the Live Reload server. If you load the `livereload.js` file created by the task, your browser will automatically reload when this message is received.
Typically, you will use this method when using a "watch" behavior so a reload can be triggered after your watch handler has been executed.

If you want to send another message to extend the behavior of the Live Reload server, you can have access to the WebSocket client using the `getWsClient()` method and send the message you want :

```
use Elephfront\RoboLiveReload\Task\Loader\LoadLiveReloadTaskTrait;

class RoboFile extends Tasks
{

    use LoadLiveReloadTaskTrait;

    public function someTask()
    {
        $this
            ->taskLiveReload()
            ->run();

        // Further down...
        $this
            ->taskLiveReload()
            ->getWsClient()
            ->send('your-message');
    }
}
```

Contributing
------------

[](#contributing)

If you find a bug or would like to ask for a feature, please use the [GitHub issue tracker](https://github.com/Elephfront/robo-live-reload/issues). If you would like to submit a fix or a feature, please fork the repository and [submit a pull request](https://github.com/Elephfront/robo-live-reload/pulls).

### Coding standards

[](#coding-standards)

This repository follows the PSR-2 standard.

License
-------

[](#license)

Copyright (c) 2017, Yves Piquel and licensed under [The MIT License](http://opensource.org/licenses/mit-license.php). Please refer to the LICENSE.txt file.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3246d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5243386?v=4)[Yves P.](/maintainers/HavokInspiration)[@HavokInspiration](https://github.com/HavokInspiration)

---

Top Contributors

[![HavokInspiration](https://avatars.githubusercontent.com/u/5243386?v=4)](https://github.com/HavokInspiration "HavokInspiration (29 commits)")

---

Tags

elephfrontroborobo-live-reloadrobo-task

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/elephfront-robo-live-reload/health.svg)

```
[![Health](https://phpackages.com/badges/elephfront-robo-live-reload/health.svg)](https://phpackages.com/packages/elephfront-robo-live-reload)
```

###  Alternatives

[drush/drush

Drush is a command line shell and scripting interface for Drupal, a veritable Swiss Army knife designed to make life easier for those of us who spend some of our working hours hacking away at the command prompt.

2.4k59.5M767](/packages/drush-drush)[pantheon-systems/terminus

A command line interface for Pantheon

3391.5M17](/packages/pantheon-systems-terminus)[chromatic/usher

A collection of Robo commands for use on Chromatic projects.

13574.9k1](/packages/chromatic-usher)[openeuropa/task-runner

PHP task runner based on Robo, focused on extensibility.

37212.5k15](/packages/openeuropa-task-runner)[boedah/robo-drush

Drush CommandStack for Robo Task Runner

22345.1k4](/packages/boedah-robo-drush)[diffy-website/diffy-cli

Diffy CLI tool.

1114.7k](/packages/diffy-website-diffy-cli)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
