Environments

Environments are at the heart of how you manage and share configuration in Ghostable. Each project can have as many environments as you need. While “production” and “staging” are common defaults, you’re free to create environments for feature testing, client-specific setups, or anything else your workflow requires. Environments store your .env variables and control how they’re organized, accessed, and shared. You can safely push, pull, or request environment data using the Ghostable CLI — all tied to a specific environment within a project.
Think of environments as named contexts for your configuration — flexible, secure, and built for collaboration.

Creating Environments

To create a new environment, run the env:init command:
ghostable env:init
You’ll be prompted to:
  • Select an environment type (e.g., Production, Staging)
  • Select a base environment or choose Standalone
  • If --name isn’t provided, choose a suggested name or enter a custom slug-formatted name

Pushing Variables

To upload your local .env file to Ghostable, use the push command:
ghostable env:push
You’ll be prompted to pick which environment to push (if --environment isn’t provided). The CLI will ask for confirmation before overwriting the server’s environment. If the environment doesn’t exist locally, it warns and offers to create it. This securely uploads your .env contents to Ghostable so they can be shared or backed up.
Note: Ghostable only pushes keys that exist in your local .env file. It does not overwrite remote keys unless they are present in your file.

Pulling Variables

To fetch a remote environment and write it to your local .env file, use the pull command:
ghostable env:pull
You’ll be prompted to pick which environment to pull (if --environment isn’t provided) and to choose a file format (with a default option). The CLI confirms before overwriting any existing file. It then downloads the latest variables and updates your local .env file.
Important: Your local .env file will be overwritten. If you have changes you want to preserve, commit or back them up before pulling.

Comparing Variables

To see differences between your local variables and those stored in Ghostable, run:
ghostable env:diff
If --environment isn’t provided, you’ll select which environment to diff. The output lists variables as added, updated, or removed.

Deploying Variables

Use env:deploy to fetch variables for deployment and load them directly into memory at runtime:
ghostable env:deploy --exec "php artisan migrate --force"
No .env file is created. The variables are injected into the command you pass with --exec. This command requires GHOSTABLE_CI_TOKEN. Add --plan to preview variable names without executing.

Validating Variables

To validate your local environment file against Ghostable, run:
ghostable env:validate
If --environment isn’t provided, you’ll select which environment to validate. Any validation errors are listed in the output.