Extra topics

Deployments

How to deploy Tempest to production.

There are many ways to deploy a PHP application. This page will list the most basic way of setting up a Tempest production server.

Prerequisites

Your server will need PHP 8.4+ and Composer at the minimum. You should also have either Bun or Node available if you chose to bundle front-end assets. While shared servers will probably work given enough configuration, it is recommended to use a dedicated server for production. The rest of this page will assume you have a server with SSH access available.

Deployment scripts

Currently, Tempest doesn't have a dedicated deployment script that comes with the framework. There will be a tempest ship command in the future, but that's still work in progress. However, creating a deployment script is very simple, given that you have SSH access.

This website, for example, has a very simple deploy command that does two things:

  • Login via SSH and pull in the latest changes from the repository.
  • Run the deploy.sh script that's included in the repository.

This deploy.sh script could look something like this:

#!/bin/bash

# Sourcing bashrc because we're connecting via SSH'
. /home/user/.bashrc

# Dependencies
composer install --no-dev
bun install

# Tempest
tempest cache:clear --force --internal --all
tempest discovery:generate
tempest migrate:up --force
tempest static:clean --force
bun run build
tempest static:generate --allow-dead-links --verbose=true

As you can see, there are a number of steps involved to deploying a Tempest project:

  • Installing composer and frontend dependencies
  • Clearing all caches and regenerating the discovery cache
  • Running migrations
  • Clean up static assets if you're using static pages
  • Compiling frontend assets
  • Finally, regenerating static pages if you're using them

Initial installation

While a deploy script handles day-by-day deployments, initial server setup requires a number of one-time steps.

First, make sure there's a .env file created in your project's root directory. Don't forget to run tempest key:generate once to create a signing key.

# Generated by `tempest key:generate`
SIGNING_KEY=…

# Set to production
ENVIRONMENT=production

# Set the base URI to your production domain
BASE_URI=https://tempestphp.com

# Enable all caches
INTERNAL_CACHES=true

# Use full discovery cache in production
DISCOVERY_CACHE=true

# Set the PHP executable path if you're using Tempest's front-end scaffolding
# See: https://tempestphp.com/2.x/getting-started/installation#scaffolding-front-end-assets
PHP_EXECUTABLE_PATH=/usr/bin/php8.4

# Any project-specific environment variables you may need.
# …

Next, make sure that the .tempest directory is writable by the web server, this is the cache directory used by Tempest. Finally, enable the scheduler.

In closing

If you find that there is anything missing from this page, please let us know by opening an issue on GitHub.