luyadev/luya-deployer 问题修复 & 功能扩展

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

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

luyadev/luya-deployer

Composer 安装命令:

composer require luyadev/luya-deployer

包简介

This is the LUYA recipe to deploy an application with Deployer, the Deployment Tool for PHP.

README 文档

README

LUYA Logo

LUYA Deployer

LUYA Total Downloads Latest Stable Version Join the chat at https://gitter.im/luyadev/luya

This is the recipe to deploy your LUYA Website with PHP Deployer.

Version 3.0 of LUYA Deployer is compatible with PHP Deployer 7

Install

Add the deployer composer package to your project:

composer require luyadev/luya-deployer --dev

Create a deploy.php file with the content of your host configuration(s) and store it in the root directory of your project:

<?php
namespace Deployer;

require 'vendor/luyadev/luya-deployer/luya.php';

// define your configuration here
host('SSHHOST.COM')
    ->setLabels(['stage' => 'prod'])
    ->set('remote_user', 'SSHUSER')
    ->set('deploy_path', '~/httpdocs');

set('repository', 'https://USER:PASSWORD@github.com/VENDOR/REPO.git');

To deploy to the above configured server just go into the console and run:

./vendor/bin/dep luya prod

The LUYA Deployer will now deploy the to the above host with prod Config. The stage() method determines which Config ENV should be taken, therefore those values must correlate each other.

Configure Hosting

In order to run your website, you have to modify the root directory of your website to current/public_html folder. Deployer will create the following folders:

  • current
  • releases
  • shared

Those folders are located in your defined deploy_path folder. So the current/public_html should be the only directory visible by the web.

Options

Several options and can be defined with set(OPTION, VALUE). Its recommend to set the define the option for a given server:

host('luya.io')
    ->stage('prod')
    ->set(COMPOSER_IGNORE_PLATFORM_REQS, true)
    ->set('deploy_path', '~/httpdocs');

Available Options

Key Constant Default Description
ignorePlatformReqs COMPOSER_IGNORE_PLATFORM_REQS false Whether composer install should ignore platform requirements or not.
adminCoreCommands LUYA_ADMIN_CORE_COMMANDS true Whether the LUYA core commands like migrate, import should be run after deployment.

In order to configure a branch to deploy use set('branch', 'myCheckoutBranch');

Unglue

In order to use unglue you can add after('luya:commands', 'unglue'); in your deploy.php. This will download the unglue phar file and compile the files according to the .unglue file. You will also need to set('unglue_server', 'https://...'); to your Unglue server URL.

Authorization Password / SSH Key

Since the password() method has been removed, authentication can either be done using SSH Keys or by entering the password while deployment. The dep luya prod command will prompt for the users password unless he could not connect by SSH Key. By default the ~/.ssh/id_rsa will be taken to make a first attempt. You can configure ssh settings with the following methods:

->configFile('~/.ssh/config')
->identityFile('~/.ssh/id_rsa')
->forwardAgent(true)
->multiplexing(true)

Read the PHP Deployer Docs for more informations. As we can not cover everything about SSH Keys but a here is a very basic example setup. First you have to create an SSH key, then the Server you'd like to connect must have stored the public key .pub file. So you should never publish the private key but the public key can be stored on the Server:

  1. Generate an SSH Key ssh-keygen -t rsa -b 2048 -C "luyadeployer"
  2. When prompting for Enter passphrase (empty for no passphrase): skip this step (at least when setting up an continuous deployment f.e.).
  3. Copy the content of ~/.ssh/id_rsa.pub which is the public key.
  4. Add the public key to ~/.ssh/authorized_keys on the Server or use ssh-copy-id. Also Plesk f.e. has visual tools to do so Plesk SSH Keys Extension

luyadev/luya-deployer 适用场景与选型建议

luyadev/luya-deployer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 57.21k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2016 年 02 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 luyadev/luya-deployer 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 57.21k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 29
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 4
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-02-26