thecodeholic/laravel-hostinger-deploy
Composer 安装命令:
composer require thecodeholic/laravel-hostinger-deploy
包简介
Laravel package for automated Hostinger deployment with GitHub Actions support
README 文档
README
Deploy your Laravel application to Hostinger shared hosting with automated GitHub Actions support.
Installation
Install the package via Composer:
composer require thecodeholic/laravel-hostinger-deploy:^0.5 --dev
Or install the latest version:
composer require thecodeholic/laravel-hostinger-deploy --dev
Note: This package should be installed as a development dependency (
--dev) since it's only needed during deployment, not in production.
Required Environment Variables
Before using any deployment commands, add these to your .env file:
HOSTINGER_SSH_HOST=your-server-ip HOSTINGER_SSH_USERNAME=your-username HOSTINGER_SSH_PORT=22 HOSTINGER_SITE_DIR=your-website-folder GITHUB_API_TOKEN=your-github-token
SSH Authentication Setup
⚠️ Important: It is highly recommended to set up SSH public key authentication on your Hostinger server instead of using password authentication. Public key authentication is more secure and eliminates the need to enter passwords during deployments.
To set up SSH public key authentication:
- Generate an SSH key pair on your local machine:
ssh-keygen -t rsa -b 4096- Copy your public key to the server:
ssh-copy-id username@your-server-ip- Test the connection:
ssh username@your-server-ip(should connect without password prompt)Once configured, the deployment commands will use your SSH key automatically, making deployments seamless and secure.
Quick Start (All-in-One Command)
The easiest way to deploy and set up automated deployment:
php artisan hostinger:deploy-and-setup-cicd
What this command does:
- Deploys your Laravel application to Hostinger
- Sets up SSH keys on the server
- Automatically adds deploy key to GitHub repository via API
- Publishes GitHub Actions workflow file locally (
.github/workflows/hostinger-deploy.yml) - Configures GitHub secrets and variables via API
Command Options:
--fresh- Delete existing files and clone fresh repository--site-dir=- Override site directory from config--token=- GitHub Personal Access Token (overrides GITHUB_API_TOKEN from .env)--branch=- Branch to deploy (default: auto-detect)--php-version=- PHP version for workflow (default: 8.3)
Individual Commands
1. Manual Deployment Only
php artisan hostinger:deploy
What it does: Deploys your Laravel application to Hostinger server (composer install, migrations, storage link, etc.)
Command Options:
--fresh- Delete existing files and clone fresh repository--site-dir=- Override site directory from config--token=- GitHub Personal Access Token (optional, enables automatic deploy key management)--show-errors- Display detailed error messages with exit codes and command output
Note: If
GITHUB_API_TOKENis provided (via.envor--tokenoption), the command will automatically add deploy keys to your GitHub repository. Otherwise, you'll be prompted to add the deploy key manually.
Incremental Deployments: The command is safe to run multiple times. It uses
git pullfor incremental updates and preserves gitignored files (like.env,storage/, etc.). Setup commands (like key generation, storage link creation) only run if needed, preventing overwrites of existing configuration.
2. Create GitHub Actions Workflow File
php artisan hostinger:publish-workflow
What it does: Creates .github/workflows/hostinger-deploy.yml file locally
Command Options:
--branch=- Branch to trigger deployment (default: auto-detect)--php-version=- PHP version for workflow (default: 8.3)
3. Setup Automated Deployment (Via GitHub API)
php artisan hostinger:setup-cicd
What it does: Publishes GitHub Actions workflow file locally and creates secrets automatically via GitHub API, and automatically adds deploy keys to your repository
Command Options:
--token=- GitHub Personal Access Token (overrides GITHUB_API_TOKEN from .env)--branch=- Branch to deploy (default: auto-detect)--php-version=- PHP version for workflow (default: 8.3)
GitHub Personal Access Token Permissions: Your GitHub Personal Access Token needs the following permissions:
- Administration → Read and write (for managing deploy keys for the repository)
- Metadata → Read-only (automatically selected, required for API access)
Note: The workflow file is published locally to .github/workflows/hostinger-deploy.yml. You'll need to review, commit, and push it manually. The command only uses the API to create secrets and deploy keys.
Environment Variables Summary
| Variable | Required For | Description |
|---|---|---|
HOSTINGER_SSH_HOST |
All commands | Hostinger server IP address |
HOSTINGER_SSH_USERNAME |
All commands | Hostinger SSH username |
HOSTINGER_SSH_PORT |
All commands | SSH port (default: 22) |
HOSTINGER_SITE_DIR |
All commands | Website folder name |
GITHUB_API_TOKEN |
Automated setup | GitHub Personal Access Token (requires Administration permission for deploy keys) |
Requirements
- PHP ^8.2
- Laravel ^11.0|^12.0
- SSH access to Hostinger server
- Git repository (GitHub recommended)
- PHP
exec()function must be enabled (required for executing SSH commands and process management)
Important: This package requires the PHP
exec()function to be available and enabled on your system. Theexec()function is used for executing SSH commands and managing deployment processes. Ifexec()is disabled in your PHP configuration, deployment operations will fail.
License
MIT
thecodeholic/laravel-hostinger-deploy 适用场景与选型建议
thecodeholic/laravel-hostinger-deploy 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8.98k 次下载、GitHub Stars 达 64, 最近一次更新时间为 2025 年 10 月 31 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「ssh」 「laravel」 「deployment」 「github-actions」 「hostinger」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 thecodeholic/laravel-hostinger-deploy 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 thecodeholic/laravel-hostinger-deploy 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 thecodeholic/laravel-hostinger-deploy 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Automated deployment template for Laravel Envoy based on Capistrano.
Morpht Development Tools
blueways deployer recipes
A Highly Opinionated Symfony3/4 Deployer Recipe
A Deployment/Change Log Schedule and Notes system for SilverStripe sites
Deployment command
统计信息
- 总下载量: 8.98k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 65
- 点击次数: 38
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-31