klytron/php-deployment-kit 问题修复 & 功能扩展

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

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

klytron/php-deployment-kit

Composer 安装命令:

composer require klytron/php-deployment-kit

包简介

A comprehensive deployment library for PHP applications built on Deployer. Supports Laravel, Yii2, and simple PHP applications.

README 文档

README

Latest Version on Packagist Total Downloads PHP Version Deployer License

A comprehensive deployment library for PHP applications built on Deployer. Supports Laravel, Yii2, API projects, and simple PHP applications with zero boilerplate.

Features

  • 🚀 Multi-Framework — Laravel, Yii2, API, and simple PHP deployment recipes
  • Zero-Config Defaults — Smart detection with easy customisation
  • 🔒 Production Safe — Multiple confirmation prompts, validation, and rollback
  • 🔑 Laravel Env Encryption — Automatic LARAVEL_ENV_ENCRYPTION_KEY decryption before deploy
  • 🗺️ Asset Mapping — Maps Vite/Mix assets for database URL compatibility
  • 🖼️ Image Optimisation — Compress images post-deploy
  • 🗂️ Sitemap Generation — Automatic sitemap creation and verification
  • 🔤 Font Verification — Checks webfonts are accessible after deploy
  • 🕒 Deployment Timing — Built-in timer and metrics
  • 🎛️ Interactive or Unattended — Prompted workflow or fully automated via auto_* flags

Requirements

  • PHP 8.1+
  • Deployer 7.x (installed automatically as a dependency)
  • Git
  • SSH access to your deployment server

Installation

Install via Composer:

composer require klytron/php-deployment-kit --dev

Verify the installation:

vendor/bin/dep --version

Optional: Scaffold a deploy.php automatically

# Auto-detect your project type (Laravel / Yii2 / simple PHP) and create deploy.php
curl -sSL https://raw.githubusercontent.com/klytron/php-deployment-kit/main/install.sh | bash

Quick Start

1. Create deploy.php in your project root

<?php
namespace Deployer;

// Core kit
require __DIR__ . '/vendor/klytron/php-deployment-kit/deployment-kit.php';

// Laravel recipe (omit for simple PHP or use klytron-php-recipe.php)
require __DIR__ . '/vendor/klytron/php-deployment-kit/recipes/klytron-laravel-recipe.php';

// ── Configure ────────────────────────────────────────────────────────────────

klytron_configure_app('my-app', 'git@github.com:your-username/my-app.git');
klytron_set_paths('/var/www', '/var/www/${APP_URL_DOMAIN}/public_html');
klytron_set_domain('yourdomain.com');
klytron_set_php_version('php8.3');

klytron_configure_project([
    'type'                  => 'laravel',
    'database'              => 'mysql',     // mysql | mariadb | postgresql | sqlite | none
    'supports_vite'         => true,
    'supports_storage_link' => true,
]);

klytron_configure_host('yourdomain.com', [
    'remote_user' => 'deploy',
    'branch'      => 'main',
    'http_user'   => 'www-data',
    'http_group'  => 'www-data',
]);

klytron_configure_shared_files(['.env']);
klytron_configure_shared_dirs(['storage', 'bootstrap/cache']);
klytron_configure_writable_dirs([
    'bootstrap/cache',
    'storage',
    'storage/logs',
    'storage/framework/cache',
    'storage/framework/sessions',
    'storage/framework/views',
]);

// ── Deployment Flow ───────────────────────────────────────────────────────────

task('deploy', [
    'klytron:deploy:start_timer',
    'klytron:laravel:deploy:display:info',
    'klytron:laravel:deploy:configure:interactive',
    'deploy:unlock',
    'deploy:setup',
    'deploy:lock',
    'deploy:release',
    'deploy:update_code',
    'deploy:shared',
    'klytron:laravel:deploy:environment:complete',
    'deploy:env',
    'deploy:vendors',
    'klytron:laravel:node:vite:build',
    'klytron:laravel:deploy:database:complete',
    'deploy:writable',
    'klytron:laravel:deploy:cache:complete',
    'deploy:symlink',
    'klytron:laravel:deploy:finalize:complete',
    'klytron:assets:map',
    'klytron:assets:cleanup',
    'klytron:sitemap:generate',
    'klytron:fonts:verify',
    'klytron:images:optimize',
    'deploy:unlock',
    'deploy:cleanup',
    'klytron:laravel:deploy:notify:complete',
    'klytron:deploy:end_timer',
])->desc('Deploy Laravel application');

2. Deploy

vendor/bin/dep deploy

Documentation

Guide Description
Installation Prerequisites, install methods, server setup
Quick Start Step-by-step first deployment
Configuration Reference All klytron_* functions and options
Function Reference API reference
Task Reference All available deployment tasks
Laravel Guide Laravel-specific configuration
Yii2 Guide Yii2-specific configuration
Simple PHP Guide Non-framework PHP projects
Dynamic Configuration Path templates and placeholders
Troubleshooting Common issues and fixes

Project Structure

php-deployment-kit/
├── deployment-kit.php          # Main entry point — include this in deploy.php
├── deployment-kit-core.php     # Core helper functions
├── klytron-tasks.php           # Framework-agnostic deployment tasks
├── recipes/
│   ├── klytron-laravel-recipe.php    # Laravel deployment tasks
│   ├── klytron-yii2-recipe.php       # Yii2 deployment tasks
│   ├── klytron-php-recipe.php        # Simple PHP tasks
│   └── klytron-server-recipe.php     # Server provisioning tasks
├── src/
│   ├── Commands/               # Laravel Artisan commands
│   ├── Exceptions/             # Custom exception classes
│   ├── Services/               # Metrics, retry, validation services
│   ├── Tasks/                  # Task classes (AssetMappingTask, SitemapTask, etc.)
│   ├── Validators/             # Configuration validators
│   └── Providers/              # Laravel service provider
├── templates/                  # Starter deploy.php templates
├── examples/                   # Real-world deployment examples
└── docs/                       # Full documentation

Supported Frameworks

Framework Recipe
Laravel recipes/klytron-laravel-recipe.php
Yii2 recipes/klytron-yii2-recipe.php
API (Laravel) recipes/klytron-laravel-recipe.php
Simple PHP recipes/klytron-php-recipe.php

Contributing

Contributions are welcome! Please read CONTRIBUTING.md first.

Security

If you discover a security vulnerability, please see SECURITY.md for how to report it responsibly.

License

MIT — see LICENSE.

📦 klytron/php-deployment-kit on Packagist
⭐ GitHub

klytron/php-deployment-kit 适用场景与选型建议

klytron/php-deployment-kit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 25 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 klytron/php-deployment-kit 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-25