klytron/php-deployment-kit

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

Fund package maintenance!
www.klytron.com/buy-me-a-coffee

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/klytron/php-deployment-kit

1.0.0 2026-02-25 05:16 UTC

This package is auto-updated.

Last update: 2026-02-25 09:12:53 UTC


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