承接 elephfront/robo-live-reload 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

elephfront/robo-live-reload

Composer 安装命令:

composer require elephfront/robo-live-reload

包简介

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

README 文档

README

Software License Build Status Codecov

This 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 using a WebSocket server.

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

Requirements

  • PHP >= 7.1.0
  • Robo

Installation

You can install this Robo task using composer.

The recommended way to install composer packages is:

composer require elephfront/robo-live-reload

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

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()

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

port()

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

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()

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

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

If you find a bug or would like to ask for a feature, please use the GitHub issue tracker. If you would like to submit a fix or a feature, please fork the repository and submit a pull request.

Coding standards

This repository follows the PSR-2 standard.

License

Copyright (c) 2017, Yves Piquel and licensed under The MIT License. Please refer to the LICENSE.txt file.

elephfront/robo-live-reload 适用场景与选型建议

elephfront/robo-live-reload 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 184 次下载、GitHub Stars 达 0, 最近一次更新时间为 2017 年 08 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 elephfront/robo-live-reload 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 elephfront/robo-live-reload 我们能提供哪些服务?
定制开发 / 二次开发

基于 elephfront/robo-live-reload 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 184
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 9
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-08-03