CLI Command Not Found: Statamic

In order for you to run globally installed Composer binaries, (like our statamic installer) you'll need to tell your computer where it's located.

If you were to run statamic in your terminal, it would have no idea you meant the one you just installed with Composer.

$ statamic new mysite
Command not found: statamic

You could use the full path to the binary instead:

$ ~/.composer/vendor/bin/statamic new mysite
Building a new statamic site.

But that's silly. Who wants to do that every time?

You can solve this by adding Composer's bin directory to your PATH (sometimes seen as $PATH).

MacOS or Linux

  1. You'll need to find Composer's global directory. This is usually somewhere in your home directory. This command will output the absolute path:

    composer global config bin-dir --absolute
  2. Identify which shell you're using. You can determine this by running echo $SHELL.

  3. Next, you'll need to add Composer's bin directory to your shell rc file. Feel free to create the file if it doesn't already exist.

    • If you're using bash, this will be ~/.bashrc
    • If you're using zsh, this will be ~/.zshrc
    # Replace the path below with the path identified in step 1
    export PATH="/Users/me/.composer/vendor/bin/":$PATH

To test it, open a new terminal window and run echo $PATH. You should see the composer directory at the end.

Windows

To add to your PATH on Windows, it requires you to click through some things. Ryan Hoffman has written an article with screenshots to walk you through it.

Composer's directory to add is %USERPROFILE%\AppData\Roaming\Composer\vendor\bin.

Docs feedback

Submit improvements, related content, or suggestions through Github.

Betterify this page →