Skip to content

Laravel Forge Deployment

This guide explains setting up and deploying to Laravel Forge staging environments.

Table of Contents


Overview

Laravel Forge is used for managing staging environments. This guide covers setting up Forge and deploying LamaPress themes.

Forge Setup

Server Provisioning

  1. Provision server in Forge
  2. Install PHP (8.4)
  3. Install Node.js (v24 LTS)
  4. Install Composer
  5. Configure web server (Nginx)

Site Creation

  1. Create site in Forge
  2. Set domain (e.g., staging.example.com)
  3. Configure web directory (public)
  4. Set PHP version (8.4)

Git Repository

  1. Connect Git repository:

    • Repository: https://github.com/lamalamanl/lamapress.git
    • Branch: main or develop
  2. Configure deployment:

    • Enable automatic deployments
    • Set deployment branch

Deployment Script

Build Assets

Deployment script should build assets:

bash
cd /home/forge/staging.example.com/wp-content/themes/lamapress
npm ci
npm run build

WordPress Setup

Ensure WordPress is set up:

bash
# WordPress should be installed in public directory
# Theme should be in wp-content/themes/lamapress

Environment Configuration

Environment Variables

Set environment variables in Forge:

  • DB_NAME - Database name
  • DB_USER - Database user
  • DB_PASSWORD - Database password
  • DB_HOST - Database host

WordPress Constants

Configure wp-config.php:

php
define('WP_DEBUG', false);
define('WP_DEBUG_LOG', false);

Deployment Process

Automatic Deployments

Forge automatically deploys on push:

  1. Push to repository
  2. Forge detects changes
  3. Runs deployment script
  4. Builds assets
  5. Deploys to server

Manual Deployments

Deploy manually in Forge:

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

Best Practices

1. Test on Staging

Always test on staging before production:

  • Verify functionality
  • Check assets load
  • Test page transitions

2. Use Environment Variables

Use environment variables for configuration:

  • Database credentials
  • API keys
  • Environment settings

3. Monitor Deployments

Monitor deployment logs:

  • Check for errors
  • Verify build success
  • Confirm asset deployment

Next Steps:

Released under the MIT License.