ethor88's avatar

Herd installation not finding PHP, Composer, Laravel

I have used Herd for a while now and really like it. I got a new machine, that was setup from scratch, and when I downloaded Herd, everything appeared to work in the Herd UI. When I went to run herd -v, php -v or any of the other checks in the docs, I got the error that the command could not be found. I couldn't find anywhere in the docs saying to update the path in the bashrc/profile, so I though I would post here in case anyone else has the issue.

echo 'export PATH="$HOME/Library/Application Support/Herd/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
3 likes
3 replies
LaryAI's avatar
Level 58

To resolve the issue of Herd not finding PHP, Composer, or Laravel on your new machine, you need to ensure that the correct paths are added to your system's PATH environment variable. This allows your terminal to locate the executables for these tools. Here's a step-by-step solution:

  1. Update the PATH in your shell configuration file:

    Depending on the shell you are using, you will need to update the appropriate configuration file. For most macOS users, this will be either ~/.bash_profile, ~/.bashrc, or ~/.zshrc (if you are using Zsh, which is the default shell in newer versions of macOS).

    Add the following line to your shell configuration file to include the Herd binaries in your PATH:

    echo 'export PATH="$HOME/Library/Application Support/Herd/bin:$PATH"' >> ~/.bash_profile
    

    If you are using Zsh, you should instead update ~/.zshrc:

    echo 'export PATH="$HOME/Library/Application Support/Herd/bin:$PATH"' >> ~/.zshrc
    
  2. Apply the changes:

    After updating the configuration file, you need to apply the changes. You can do this by sourcing the file:

    For Bash:

    source ~/.bash_profile
    

    For Zsh:

    source ~/.zshrc
    
  3. Verify the installation:

    After updating and sourcing your configuration file, verify that the commands are now recognized by your terminal:

    herd -v
    php -v
    composer -v
    laravel -v
    

    Each of these commands should now return version information, indicating that they are correctly installed and accessible.

By following these steps, you should be able to resolve the issue and have Herd, PHP, Composer, and Laravel available in your terminal.

Batman55's avatar

@ethor88 ~/.zshrc is what your looking for on a Mac.

To check yours:

nano ~/.zshrc

Here is a copy of my Herd configuration for you reference, {{user}} is where your username will be for your machine:

alias sail='[ -f sail ] && bash sail || bash vendor/bin/sail'
export PATH="/Users/{{user}}/.config/herd-lite/bin:$PATH"
export PHP_INI_SCAN_DIR="/Users/{{user}}/.config/herd-lite/bin:$PHP_INI_SCAN_DIR"


# Herd injected PHP 8.3 configuration.
export HERD_PHP_83_INI_SCAN_DIR="/Users/{{user}}/Library/Application Support/Herd/config/php/83/"


# Herd injected NVM configuration
export NVM_DIR="/Users/{{user}}/Library/Application Support/Herd/config/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

[[ -f "/Applications/Herd.app/Contents/Resources/config/shell/zshrc.zsh" ]] && builtin source "/Applications/Herd.app/C$

# Herd injected PHP binary.
export PATH="/Users/{{user}}/Library/Application Support/Herd/bin/":$PATH
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PATH="/usr/local/opt/[email protected]/sbin:$PATH"
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PATH="/usr/local/opt/[email protected]/sbin:$PATH"


# Herd injected PHP 8.4 configuration.
export HERD_PHP_84_INI_SCAN_DIR="/Users/{{user}}/Library/Application Support/Herd/config/php/84/"

export PATH="$PATH:/Users/{{user}}/.composer/vendor/bin"
RemiM's avatar

If you’re using Zsh but Herd update or try to update ~/.bash_profile, the changes won’t take effect.

  1. Add this line to your shell configuration file:
# Herd injected PHP binary.
export PATH="/Users/{yourusername}/Library/Application Support/Herd/bin:$PATH
  1. Apply the changes:
source ~/.zshrc

Now when you run herd -vit should work fine.

Please or to participate in this conversation.