Skip to content

Deployment Guide

This guide covers deploying LamaPress themes to staging and production environments using Laravel Forge.

Table of Contents

Overview

LamaPress deployments typically follow this flow:

  1. Development - Local development with Herd
  2. Staging - Laravel Forge staging environment
  3. Production - Laravel Forge production environment

Pre-Deployment Checklist

Before deploying, ensure:

  • [ ] All code is committed to GitHub
  • [ ] Production build completed (npm run build)
  • [ ] Build files committed (dist/ directory)
  • [ ] Database migrations completed (if any)
  • [ ] Environment variables configured
  • [ ] Dependencies updated (composer install, npm install)
  • [ ] Tests passed (if applicable)
  • [ ] Code review completed

Building for Production

bash
# Build production assets
npm run build

# Commit build files
git add dist/
git commit -m "Build production assets"
git push

Important: Always commit the dist/ directory with production builds.

Laravel Forge Setup

Initial Setup

  1. Connect Repository - Link GitHub repository to Forge
  2. Configure Server - Set up PHP version, Node.js version
  3. Set Deployment Script - Configure deployment commands
  4. Environment Variables - Set up environment-specific configs

Server Requirements

  • PHP 8.4 (or as required by WordPress)
  • Node.js v24 LTS
  • Composer
  • Git

Deployment Script

Typical Forge deployment script:

bash
cd /home/forge/your-site.com
git pull origin main

# Install PHP dependencies
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev

# Install Node dependencies
npm ci

# Build assets
npm run build

# Clear caches (if applicable)
wp cache flush

Deployment Process

Automatic Deployment

Forge can automatically deploy on push:

  1. Push to GitHub - Push to main/master branch
  2. Forge Detects - Forge detects the push
  3. Runs Script - Executes deployment script
  4. Deploys - Updates files and runs commands

Manual Deployment

Deploy manually from Forge dashboard:

  1. Go to site in Forge
  2. Click "Deploy Now"
  3. Monitor deployment logs
  4. Verify deployment success

Deployment Steps

  1. Pull Code - git pull origin main
  2. Install Dependencies - composer install, npm ci
  3. Build Assets - npm run build
  4. Clear Caches - WordPress and application caches
  5. Run Migrations - Database updates (if any)

Environment Configuration

WordPress Configuration

Set environment-specific constants in wp-config.php:

php
// Development
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);

// Staging
define('WP_DEBUG', false);
define('WP_DEBUG_LOG', false);

// Production
define('WP_DEBUG', false);
define('WP_DEBUG_LOG', false);

Environment Variables

Use Forge's environment variables for sensitive data:

bash
# In Forge environment variables
LL_BUNNY_API_KEY=your_key_here
LL_GTM_ID=GTM-XXXXXXX

Access in wp-config.php:

php
define('LL_BUNNY_API_KEY', env('LL_BUNNY_API_KEY'));

Theme Constants

LamaPress constants in wp-config.php:

php
// Optional: Google Tag Manager
define('LL_GTM_ID', '');

// Optional: Cookie Consent
define('LL_COOKIE_CONSENT', '');
define('LL_COOKIEBOT_ID', '');

// Optional: Bunny.net
define('LL_BUNNY_API_KEY', '');
define('LL_BUNNY_LIBRARY_ID', '');
define('LL_BUNNY_PULL_ZONE', '');

Post-Deployment

Verification Steps

  1. Check Site - Visit site and verify it loads
  2. Check Assets - Verify CSS/JS are loading
  3. Check Console - No JavaScript errors
  4. Test Functionality - Test key features
  5. Check Performance - Run Lighthouse audit

Common Issues

Assets Not Loading:

  • Verify dist/ directory exists
  • Check file permissions
  • Verify manifest file exists

Styles Not Applied:

  • Clear browser cache
  • Check CSS files are loading
  • Verify build completed successfully

JavaScript Errors:

  • Check browser console
  • Verify all dependencies installed
  • Check for missing files

Best Practices

1. Always Test on Staging

Deploy to staging first, then production:

Development → Staging → Production

2. Use Environment Variables

Never commit sensitive data:

php
// ✅ Good
define('API_KEY', env('API_KEY'));

// ❌ Bad
define('API_KEY', 'hardcoded-key');

3. Monitor Deployments

Watch deployment logs for errors:

  • Check Forge deployment logs
  • Monitor error logs
  • Set up error tracking

4. Rollback Plan

Keep previous deployment available:

  • Tag releases in Git
  • Keep backups
  • Document rollback procedure

5. Database Backups

Always backup before deployment:

  • Use Forge backup feature
  • Manual database export
  • Test restore procedure

Next Steps:

Released under the MIT License.