3.9 KiB
Laravel Hostinger Deploy
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.1 --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.
Quick Start (All-in-One Command)
The easiest way to deploy and set up automated deployment:
php artisan hostinger:deploy-and-setup-automated
Required Environment Variables
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
What this command does:
- Deploys your Laravel application to Hostinger
- Sets up SSH keys on the server
- Creates GitHub Actions workflow file
- 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 API 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-shared
What it does: Deploys your Laravel application to Hostinger server (composer install, migrations, storage link, etc.)
Required Environment Variables:
HOSTINGER_SSH_HOSTHOSTINGER_SSH_USERNAMEHOSTINGER_SSH_PORTHOSTINGER_SITE_DIR
Command Options:
--fresh- Delete existing files and clone fresh repository--site-dir=- Override site directory from config
2. Setup Automated Deployment (Manual)
php artisan hostinger:auto-deploy
What it does: Generates SSH keys on server and displays GitHub secrets/variables for manual setup
Required Environment Variables:
HOSTINGER_SSH_HOSTHOSTINGER_SSH_USERNAMEHOSTINGER_SSH_PORTHOSTINGER_SITE_DIR
No options - Run this command, then manually add the displayed secrets to GitHub
3. Create GitHub Actions Workflow File
php artisan hostinger:publish-workflow
What it does: Creates .github/workflows/hostinger-deploy.yml file locally
Required Environment Variables: None (must be in a Git repository)
Command Options:
--branch=- Branch to trigger deployment (default: auto-detect)--php-version=- PHP version for workflow (default: 8.3)
4. Setup Automated Deployment (Via GitHub API)
php artisan hostinger:setup-automated-deploy
What it does: Creates GitHub Actions workflow and secrets automatically via GitHub API
Required Environment Variables:
HOSTINGER_SSH_HOSTHOSTINGER_SSH_USERNAMEHOSTINGER_SSH_PORTHOSTINGER_SITE_DIRGITHUB_API_TOKEN
Command Options:
--token=- GitHub API token (overrides GITHUB_API_TOKEN from .env)--branch=- Branch to deploy (default: auto-detect)--php-version=- PHP version for workflow (default: 8.3)
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 (repo, workflow scopes) |
Requirements
- PHP ^8.2
- Laravel ^11.0|^12.0
- SSH access to Hostinger server
- Git repository (GitHub recommended)
License
MIT