Skip to content

Create Staging Environment

The lamapress:staging command creates a new staging environment for a WordPress site on Laravel Forge. It automates the entire process of setting up a staging site, including database creation, DNS configuration, SSL installation, and deployment.

Usage

bash
clli lamapress:staging [subdomain]

Arguments

  • subdomain (optional) - The subdomain for the staging environment. If not provided, you'll be prompted.

Options

  • -v, --verbose - Enable verbose output for debugging

Prerequisites

Before running this command, ensure you have configured:

  • forge_token - Laravel Forge API token
  • forge_server_id - Forge server ID
  • cloudflare_token - Cloudflare API token
  • cloudflare_zone_id - Cloudflare zone ID

See Configuration for details on setting these up.

Process

The command performs these steps:

  1. Verifies you're in a theme directory
  2. Checks CLLI configuration for required keys
  3. Creates a new isolated PHP site on Forge
  4. Sets up the database
  5. Configures Cloudflare DNS
  6. Installs SSL certificate
  7. Installs your SSH key
  8. Sets up deployment scripts
  9. Installs WordPress
  10. Installs plugins
  11. Installs theme
  12. Migrates local environment to staging
  13. Sets up final deployment script
  14. Updates git remote
  15. Enables quick deploy

Requirements

  • Must be run from within a WordPress theme directory
  • Theme must be in a Git repository
  • You must have access to the Laravel Forge server
  • You must have Cloudflare access for DNS configuration

Examples

Create staging with subdomain:

bash
cd wp-content/themes/my-theme
clli lamapress:staging myproject-staging

Interactive mode:

bash
cd wp-content/themes/my-theme
clli lamapress:staging

Verbose mode:

bash
clli lamapress:staging myproject-staging -v

Configuration

The command will prompt you for any missing configuration keys. You can also set them beforehand using:

bash
clli config:update

What Gets Created

Site Configuration

  • Domain: {subdomain}.lamalama.dev
  • PHP Version: PHP 8.3
  • Site Type: Isolated PHP site
  • Directory: /public

Database

  • Automatically generated database name, username, and password
  • Database credentials are displayed after creation

WordPress Installation

  • Fresh WordPress installation
  • Admin user: Lama Lama
  • Admin email: wordpress@lamalama.nl
  • Randomly generated admin password (displayed after creation)

Plugins Installed

  • WP Migrate DB Pro (activated and configured)
  • All default WordPress plugins removed (Akismet, Hello Dolly)

Theme

  • Theme cloned from your Git repository
  • Default WordPress themes removed
  • Assets built automatically

After Running

Once the command completes, you'll see output like:

Staging site ready on [https://myproject-staging.lamalama.dev]. Build something unexpected.
Admin ready on [https://myproject-staging.lamalama.dev/wp-admin]. Manage your website here.

Key                    Value
site domain:          myproject-staging.lamalama.dev
server username:      u_myproject_staging_lamalama_dev_...
Site id:              12345
DB name                db_myproject_staging_...
DB username           dbu_myproject_staging_...
DB password            [random-password]

Important: Save the database credentials and admin password shown in the output.

Troubleshooting

Not in Theme Directory

Not in theme directory:

  • Ensure you're in wp-content/themes/your-theme/
  • The command checks for this automatically

Missing Configuration

Missing configuration:

  • Run clli config:show to see what's configured
  • Use clli config:update to add missing keys
  • The command will prompt for missing required keys

Forge API Errors

Forge API errors:

  • Verify your Forge token is valid
  • Check that you have access to the specified server
  • Ensure the server has available resources

Cloudflare Errors

Cloudflare errors:

  • Verify your Cloudflare token has DNS edit permissions
  • Check that the zone ID is correct
  • Ensure the subdomain doesn't already exist

Organization ID Issues

If you see an error about organization ID:

  • Your organization has multiple owners and requires an organization ID
  • Find your organization ID in the Forge dashboard URL: https://forge.laravel.com/organizations/{organization_id}/servers
  • Set it manually: clli config:update forge_organization_id

Migration Issues

If the local-to-remote migration fails:

  • Ensure WP Migrate DB Pro is installed and activated locally
  • Check that your local WordPress installation is accessible
  • Verify the connection key is correct
  • Check for version mismatches between local and remote WP Migrate DB plugins

Released under the MIT License.