Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

SteamDiesel's avatar

Referencing ENV in Envoyer deployments

I have been trying to deploy my app with envoyer and I'm bumping into a problem. I use nova, so composer needs to check the licence while downloading. I use a deployment hook like this

cd {{ release }}
composer config http-basic.nova.laravel.com "${NOVA_USERNAME}" "${NOVA_LICENSE_KEY}"

I have checked that the details are correct and in the ENV file managed by Envoyer, following the docs.

After further troubleshooting, I've added some logging to the hook, like this:

cd {{ release }}
composer config http-basic.nova.laravel.com "${NOVA_USERNAME}" "${NOVA_LICENSE_KEY}"
echo "NOVA_USERNAME: ${NOVA_USERNAME}"
echo "NOVA_LICENSE_KEY: ${NOVA_LICENSE_KEY}"
echo "APP_NAME: ${APP_NAME}"
echo "APP_URL: ${APP_URL}"
ls -la ~/.composer
cat ~/.composer/auth.json

The output of this shows this:

NOVA_USERNAME: 
NOVA_LICENSE_KEY: 
APP_NAME: 
APP_URL: 
ls: cannot access '/home/forge/.composer': No such file or directory
cat: /home/forge/.composer/auth.json: No such file or directory

I am starting to think this issue is not a skill issue, but maybe a bug in the project deployment?

0 likes
2 replies
LaryAI's avatar
Level 58

The issue you're encountering seems to be related to environment variables not being correctly passed or recognized during the deployment process with Envoyer. Here are a few steps you can take to troubleshoot and resolve this issue:

  1. Verify Envoyer Environment Variables: Ensure that the environment variables (NOVA_USERNAME, NOVA_LICENSE_KEY, APP_NAME, APP_URL) are correctly set in the Envoyer project settings. Double-check for any typos or incorrect values.

  2. Use Envoyer's Environment Variables: Envoyer allows you to manage environment variables directly. Make sure these variables are set in the "Environment" section of your Envoyer project. This ensures they are available during deployment.

  3. Check Deployment Hooks: Ensure that the deployment hook is set to run in the correct stage of the deployment process. For example, if you're using these variables during the "Install Composer Dependencies" stage, make sure the hook is set to run before this stage.

  4. Use export Command: Sometimes, explicitly exporting the variables can help. Modify your deployment hook to include export:

    cd {{ release }}
    export NOVA_USERNAME="${NOVA_USERNAME}"
    export NOVA_LICENSE_KEY="${NOVA_LICENSE_KEY}"
    composer config http-basic.nova.laravel.com "${NOVA_USERNAME}" "${NOVA_LICENSE_KEY}"
    echo "NOVA_USERNAME: ${NOVA_USERNAME}"
    echo "NOVA_LICENSE_KEY: ${NOVA_LICENSE_KEY}"
    echo "APP_NAME: ${APP_NAME}"
    echo "APP_URL: ${APP_URL}"
    
  5. Check User Permissions: The error regarding /home/forge/.composer suggests a permissions issue or that the directory does not exist. Ensure that the user running the deployment has the necessary permissions and that the directory exists. You might need to create the directory manually or adjust permissions.

  6. Debugging: Add additional logging to see if the environment variables are being set at any point. You can also try running a simple script to output all environment variables to see if they are being set at all:

    cd {{ release }}
    printenv
    
  7. Contact Envoyer Support: If none of the above steps resolve the issue, it might be worth reaching out to Envoyer support for further assistance, as there could be a specific issue with how Envoyer is handling environment variables in your setup.

By following these steps, you should be able to identify where the problem lies and take corrective action.

SteamDiesel's avatar

alright, I have resolved the missing ENV issue. I've re-saved each server and re-saved the env file and now the env credentials are showing in the log output at least.

turns out you need to specify the env for this to work.

cd {{ release }}

source .env

composer config http-basic.nova.laravel.com "${NOVA_USERNAME}" "${NOVA_LICENSE_KEY}"
echo "APP_NAME: ${APP_NAME}"
echo "APP_URL: ${APP_URL}"

deployment is successful on both servers

Please or to participate in this conversation.