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

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

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

klytron/php-deployment-kit

最新稳定版本:v1.0.3

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

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固