承接 felippe-regazio/php-hot-reloader 相关项目开发

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

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

felippe-regazio/php-hot-reloader

Composer 安装命令:

composer require felippe-regazio/php-hot-reloader

包简介

A class to add a complete live reload feature to any php project

README 文档

README

[UNMAINTAINED]: This repository is currently unmaintained, I've been very busy in the last months and im struggling to find some time to take care of this repo but with no success. I'm sorry for those who are using it. If you want to maintain this repo, please open an issue and let me know.

This is a class that adds a live reload feature to any php project. It allows you to see your page dynamically changing while coding, without have to keep refreshing the browser on every change.

This Reloader uses a SSE (server-sent events) to listen to changes and notify the browser. So, no built-in server, no custom port, no pain configuration needed.

Installing

Using Composer

composer require felippe-regazio/php-hot-reloader:dev-master --prefer-source

Manually

Clone this repository and copy its folder to somewhere on your project.

Configuring

  1. Copy the phrwatcher.php file on the repository root to somewhere on your app. This file must be available through some URL (you can change its name if you prefer), and if you visit this file you must see the message "SSE_ADDRESS_OK | PROJECT ROOT:" informing your project root. Copy this URL, you'll gonna need it.

  2. Open this file and configure the $variables according to your needings. Please, read the doc strings on the vars to properly configure them. Basically you will inform your app root on $PROJECT_ROOT, files to watch and files to ignore relative to the app root on $WATCH and $IGNORE.

  3. Now, lets imagine that you have configured your phrwatcher.php and it is available on the URL http://localhost/your-project/phrwatcher.php (the URL that you copied on the first step). Now, you must activate the reloader by calling it on your application and pointing it to this URL like this:

require_once "/php-hot-reloader/src/HotReloader.php";
new HotReloader\HotReloader('//localhost/your-project/phrwatcher.php');

If you installed this repository using composer, you dont need the require_once, just add the "autoloader" on your app and call the reloader.

So, you must pass the address that points to your phrwatcher.php file as the HotReloader() function param. You dont need to add the protocol, just add "//" as URL prefix. Is highly recommended to start the HotReloader on some front controller on your app. Also you should deactivate the reloader on production, never keep this feature active on production.

Git Integration

The $WATCH variable on the phrwatcher.php file defines the files and folders to track. So, instead of set a list of files and folder and observe them, you can Observe your repository. The Hot Reloader will use git to track the files currently being changed and watch them. This saves a lot of time and processing, since the files being tracked are updated automatically, and reserved only to the files that you are working on the moment. To track using GIT you must set your $WATCH variable like this:

$WATCH = "git:your/absolute/repository/path/";

If your phrfile.php is in your project root, you can use an automatic and dynamic version:

$WATCH = "git:" . __DIR__;

Now the Hot Reloader will automatically observe the files using your Git Status.

Tips

When working with larger projects, the diff algorithm can take some time to calc the modified files. To avoid the "input lag", you can follow this tips:

  1. On the $WATCH array of your phrwatcher.php try to keep only the necessary. If your project is huge, avoid using ".", and especify path by path, avoiding unecessary huge folders as vendors, tmp, log. Or consider use the Git Integration.

  2. The $IGNORE array is related only to what you are watching. If any vendor folder on the paths that you are watching, you must add them to your ignore list. Paths such as vendor, node_modules, sass_cache, tmp, log, keep them ignored.

  3. If your project is really big, is recomended to add the 'git' mode to your $WATCH list. So, your list will be always the result of a git status, consequently, you will be watching always the files that you are currently working on.

Example

There is an example file on the root of this repository. The example.php. Open this file on your browser to see the Hot Reloader working.

felippe-regazio/php-hot-reloader 适用场景与选型建议

felippe-regazio/php-hot-reloader 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.42k 次下载、GitHub Stars 达 107, 最近一次更新时间为 2020 年 03 月 05 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 felippe-regazio/php-hot-reloader 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 3.42k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 107
  • 点击次数: 17
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 107
  • Watchers: 6
  • Forks: 30
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-05