承接 thetamari/laravel-hostinger 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

thetamari/laravel-hostinger

最新稳定版本:v1.0.6

Composer 安装命令:

composer require thetamari/laravel-hostinger

包简介

A Laravel package to deploy private GitHub repositories to Hostinger shared hosting via SSH, with automated webhook-based auto-deployment on push.

README 文档

README

Latest Version on Packagist License

A Laravel Composer package for deploying private GitHub repositories to Hostinger shared hosting via SSH, with full auto-deploy on push via GitHub webhooks.

Hostinger shared hosting does not support server-side git hooks, does not let you change the web root away from public_html, and its built-in GitHub auto-deploy only copies into public_html — making it unsuitable for Laravel. This package solves all of that.

Table of Contents

How it works

~/domains/yourdomain.com/                 ← Laravel lives here (cloned from GitHub)
~/domains/yourdomain.com/public_html      → symlink → ~/domains/yourdomain.com/public

When you push to GitHub, a webhook fires your Hostinger-hosted receiver, which triggers php artisan hostinger:deploy --pull-only in the background — pulling code, running composer, npm run build, migrating, and caching automatically.

Requirements

  • PHP 8.1+
  • Laravel 10, 11, or 12
  • SSH access enabled on your Hostinger plan (Business or above)
  • An SSH key pair added to Hostinger hPanel → SSH Keys
  • Composer installed on Hostinger (available via hPanel)
  • Node.js available via /opt/alt/alt-nodejs24 (or adjust the path in config)

Installation

  1. Install the package, then run the prepare command to patch your project files:
   composer require thetamari/laravel-hostinger
   php artisan hostinger:prepare

Optionally publish the config file if you want to customize it directly:

   php artisan vendor:publish --tag=hostinger-deploy-config
  1. Fill in your local .env with all HOSTINGER_* values from the Configuration section below.
  2. ⚠⚠ Important: Commit and push your project to GitHub before the next step.
  3. Run the deploy command locally on your computer — this SSHs into Hostinger, clones your repo, installs dependencies, and sets everything up:
   php artisan hostinger:deploy
  1. Once the first deploy is done, run the webhook setup command to get the details needed for GitHub:
   php artisan hostinger:setup-webhook

From this point on, every push to your branch triggers an automatic re-deploy via the GitHub webhook.

Configuration

Add the following values to your .env and .env.example files. The SSH values are only required locally on your computer for initial deployment, but the rest are needed for the remainder of the functionality:

# SSH connection to Hostinger
# Port is typically 65002 on Hostinger shared hosting
HOSTINGER_SSH_HOST=
HOSTINGER_SSH_PORT=65002
HOSTINGER_SSH_USER=
HOSTINGER_SSH_KEY_PATH=~/.ssh/id_rsa
HOSTINGER_SSH_KEY_PASSPHRASE=

# The folder name inside ~/domains/ on Hostinger
# e.g. if your site lives at ~/domains/yourdomain.com → HOSTINGER_WEBSITE_FOLDER=yourdomain.com
HOSTINGER_WEBSITE_FOLDER=
HOSTINGER_WEBSITE_URL=https://yourdomain.com

# PHP, Node, and Composer binary paths on Hostinger
# Adjust version numbers to match what you've selected in hPanel
HOSTINGER_PHP_BIN=/opt/alt/php85/usr/bin/php
HOSTINGER_COMPOSER_BIN=/usr/local/bin/composer
HOSTINGER_NODE_BIN=/opt/alt/alt-nodejs24/root/usr/bin/node
HOSTINGER_NPM_BIN=/opt/alt/alt-nodejs24/root/usr/bin/npm

# Adjust node memory limit for shared hosting
HOSTINGER_NODE_MEMORY_LIMIT=512

# GitHub fine-grained PAT (Personal Access Token)
# Required permissions:
#   - Contents: Read-only
#   - Metadata: Read-only (granted automatically)
# If using a classic PAT, enable the `repo` scope.
HOSTINGER_GITHUB_PAT=
HOSTINGER_GITHUB_REPO=username/repo-name
HOSTINGER_GITHUB_BRANCH=main

# Webhook
# Secret must match what you enter in GitHub's webhook settings
# Generate one with: openssl rand -hex 32
HOSTINGER_WEBHOOK_SECRET=
HOSTINGER_WEBHOOK_ROUTE=deploy/webhook

# Remote log file path on Hostinger
# Use the full path inside your Laravel project for best results
# Leave empty to disable remote logging
HOSTINGER_LOG_PATH=~/domains/yourdomain.com/storage/logs/deploy.log

GitHub PAT Permissions

Create a fine-grained PAT at github.com/settings/tokens with:

Permission Access
Contents Read-only
Metadata Read-only (auto-granted)

If using a classic PAT, enable the repo scope.

Commands

Prepare your project

Run once before your first push to patch your project files:

php artisan hostinger:prepare

This adds the webhook route to your CSRF exclusions in bootstrap/app.php and adds .rnd to your .gitignore. On Laravel 10 the CSRF patch is not automatic — see the Auto-deploy setup section.

First-time deploy

Clones the repo, runs composer install, sets up .env, generates an app key, runs migrations, builds assets, and creates the public_html and storage symlinks.

php artisan hostinger:deploy

The command will pause after copying .env.example to .env so you can SSH in (or use Hostinger's file manager for your website) and fill in production values before continuing. It's important to fill in the HOSTINGER_* values too (except SSH values).

It will also pause if migration fails because of database connection issues and give you the opportunity to fix them then continue without starting over.

Options:

Option Description
--skip-npm Skip npm install and npm run build
--skip-migrate Skip database migrations
--run-npm Force npm build
--pull-only Pull latest code and run post-deploy steps only (no wipe/clone)
--ssh Run pull-only via SSH from your local machine instead of directly on the server

Re-deploy (code update only)

php artisan hostinger:deploy --pull-only --run-npm

Pulls the latest code, runs composer install, migrations, and rebuilds the cache. Also runs npm install and npm run build. Does not wipe the directory or touch .env.

To manually trigger a re-deploy from your local machine via SSH:

php artisan hostinger:deploy --pull-only --ssh --run-npm

Set up auto-deploy webhook

php artisan hostinger:setup-webhook

This prints your webhook URL, generates a secret if you don't have one, and gives you the exact GitHub settings to use.

Auto-deploy setup (after first deploy)

The webhook is a standard Laravel POST route registered by the package — no standalone PHP files, no public directory hacks.

Running hostinger:prepare automatically adds the webhook route to your CSRF exclusions in bootstrap/app.php. On Laravel 10 this is not patched automatically — add it manually to app/Http/Middleware/VerifyCsrfToken.php:

protected $except = [
    'deploy/webhook',
];

1. Run php artisan hostinger:setup-webhook — this will give you your webhook URL and secret.

2. Create the webhook — Use the printed details to add a webhook in your GitHub repo → Settings → Webhooks → Add webhook:

  • Payload URL: https://yourdomain.com/deploy/webhook
  • Content type: application/json
  • Secret: your HOSTINGER_WEBHOOK_SECRET
  • Events: Just the push event

3. Push to your branch. GitHub sends a signed payload to your Laravel app, which verifies the HMAC-SHA256 signature and runs hostinger:deploy --pull-only in the background. The webhook always runs npm run build.

Security note: The URL itself does not need to be obscure. Every request is verified against a cryptographic signature using your HOSTINGER_WEBHOOK_SECRET. Requests without a valid signature are rejected with a 403 before any deploy logic runs.

Logging

All deploy activity is logged to the remote path defined in HOSTINGER_LOG_PATH (default: ~/domains/yourdomain.com/storage/logs/deploy.log). You can tail it:

ssh -p 65002 user@yourhost "tail -f ~/domains/yourdomain.com/storage/logs/deploy.log"

Set HOSTINGER_LOG_PATH= (empty) to disable remote logging.

A lock file (storage/logs/hostinger-deploy.lock) is created at the start of each webhook-triggered deploy and removed when it completes. If two pushes arrive simultaneously, the second is skipped since the first deploy will already include the latest code. Stale lock files older than 10 minutes are automatically removed.

PHP & Node version

Hostinger uses alt-php and alt-nodejs from CloudLinux. Default paths in this package:

PHP:  /opt/alt/php85/usr/bin/php
Node: /opt/alt/alt-nodejs24/root/usr/bin/node
npm:  /opt/alt/alt-nodejs24/root/usr/bin/npm

If your hPanel is configured to use a different version, update HOSTINGER_PHP_BIN, HOSTINGER_NODE_BIN, and HOSTINGER_NPM_BIN accordingly.

Also, make sure to set the HOSTINGER_NODE_MEMORY_LIMIT value as unlimited memory values can crash your npm run build command especially on low memory shared hosting environments.

Security

  • Your GitHub PAT is used only over HTTPS and never stored on the remote server beyond the git remote URL (which is reset on each pull). Consider rotating it periodically.
  • The webhook endpoint validates the X-Hub-Signature-256 header using HMAC-SHA256. Requests with an invalid or missing signature are rejected with a 403.
  • Never commit your .env or expose your PAT or webhook secret.

License

MIT — see LICENSE.

Author

TheTamari · github.com/thetamari

Credits

Inspired by TheCodeHolic · github.com/thecodeholic

thetamari/laravel-hostinger 适用场景与选型建议

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

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

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

围绕 thetamari/laravel-hostinger 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-22