uuf6429/electron-installer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

uuf6429/electron-installer

Composer 安装命令:

composer require uuf6429/electron-installer

包简介

A Composer package which installs the Electron binary (Linux, Windows, Mac) into `/bin` of your project.

README 文档

README

Packagist Build Status License

A Composer package which installs the Electron binary (Linux, Windows, Mac) into /bin of your project.

Table of Contents

Installation

To install Electron as a local, per-project dependency to your project, simply add a dependency on uuf6429/electron-installer to your project's composer.json file.

{
  "require": {
    "uuf6429/electron-installer": "^2"
  },
  "scripts": {
    "post-install-cmd": [
      "ElectronInstaller\\Installer::installElectron"
    ],
    "post-update-cmd": [
      "ElectronInstaller\\Installer::installElectron"
    ]
  }
}

For a development dependency, change require to require-dev.

The default download source used is: https://github.com/electron/electron/releases/ You might change it by setting a custom CDN URL, which is explained in the section "Downloading from a mirror".

By setting the Composer configuration directive bin-dir, the vendor binaries will be installed into the defined folder. Important! Composer will install the binaries into vendor\bin by default.

The scripts section is necessary, because currently Composer does not pass events to the handler scripts of dependencies. If you leave it away, you might execute the installer manually.

Now, assuming that the scripts section is set up as required, the Electron binary will be installed into the /bin folder and updated alongside the project's Composer dependencies.

How to require specific versions of Electron?

The environment and server variable ELECTRON_VERSION enables you specify the version requirement at the time of packaging.

You can also set the electron-version in the extra section of your composer.json:

{
  "extra": {
    "uuf6429/electron-installer": {
      "electron-version": "16.0.0"
    }
  }
}

The search order for the version is $_ENV, $_SERVER, composer.json (extra section), fallback to the latest version on GitHub.

How does this work internally?

Fetching the Electron Installer

In your composer.json you require the package "electron-installer". The package is fetched by composer and stored into ./vendor/uuf6429/electron-installer. It contains only one file the ElectronInstaller\\Installer.

Platform-specific download of Electron

The ElectronInstaller\\Installer is run as a "post-install-cmd". That's why you need the "scripts" section in your " composer.json". The installer creates a new composer in-memory package "electron", detects your OS and downloads the correct Electron version to the folder ./vendor/uuf6429/electron. All Electron files reside there.

Installation into /bin folder

The binary is linked from ./vendor/uuf6429/electron to your composer configured bin-dir folder.

Generation of ElectronBinary

The installer generates a PHP file ElectronInstaller/ElectronBinary and inserts the path to the binary.

ElectronBinary

To access information about the binary, the class ElectronBinary is created automatically during installation.

The class defines the following constants:

  • BIN is the full-path to the Electron binary file, e.g. /your_project/bin/electron
  • DIR is the folder of the binary, e.g. /your_project/bin
  • VERSION the version used during the installation, e.g. 16.1.2

Usage:

<?php 

use ElectronInstaller\ElectronBinary;

$bin = ElectronBinary::BIN;
$dir = ElectronBinary::DIR;
$version = ElectronBinary::VERSION;

Override platform requirements

The environment and server variables ELECTRON_PLATFORM and ELECTRON_ARCHITECTURE enable you to override the platform requirements at the time of packaging. This decouples the packaging system from the target system. It allows to package on Linux for MacOSX or on Windows for Linux.

Possible values for

  • ELECTRON_PLATFORM are: darwin, win32, linux.
  • ELECTRON_ARCHITECTURE are: ia32or x64.

Downloading from a mirror

You can override the default download location of the Electron binary file by setting it in one of these locations:

  • The environment variable ELECTRON_CDNURL
  • The server variable ELECTRON_CDNURL
  • In your composer.json by using $['extra']['uuf6429/electron-installer']['cdnurl']:
{
 "extra": {
   "uuf6429/electron-installer": {
     "cdnurl": "https://github.com/company/electron/releases/download/v16.0.0/"
   }
 }
}

Default Download Location

The default download location is GitHub: https://github.com/electron/electron/releases/. You don't need to set it explicitly. It's used when ELECTRON_CDNURL is not set.

Automatic download retrying with version lowering on 404

In case downloading an archive fails with HttpStatusCode 404 (resource not found), the downloader will automatically lower the version to the next available version and retry.

A couple of notes on this behaviour:

  • The number of retries is determined by the number of Electron versions in getElectronVersions().
  • Since you can only request one specific version, it is possible to fall back to a very old version, if all others failed for some reason.
  • On the next composer update/install, it will go through this process again. Therefore, it is possible that having a lot of broken versions could slow the installation process.

uuf6429/electron-installer 适用场景与选型建议

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

它主要适用于以下技术方向: 「headless」 「binaries」 「electron」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 uuf6429/electron-installer 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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