Forge-CLI, a Command Tool for Laravel Forge Servers

Posted by Adam Engebretson on July 23, 2014

Laravel Forge has been out for just over two months now, and has gained outstanding popularity within the Laravel community, and has also attracted the attention of non-Laravel developers. It truly has done exactly what it was set out to do: "Super simple from download to deployment."

Forge works by accessing your VPS via SSH and executing the commands for you, giving you a nice graphical interface for managing your server (emphasis on the "your"). However, sometimes it's more of an inconvenience to log into the Forge website to check on something, especially when you're already SSH'd into a Forge server. The solution: Forge-CLI.

The Forge-CLI is designed to help you review the configurations that Laravel Forge has made on your server, as well as inspect deployment scripts and logs. Installation is simple, and using it will be incredibly familiar to Laravel users, since it's built with the Symfony Console component.

To install Forge-CLI, execute the following commands:

$ wget https://raw.githubusercontent.com/adamgoose/forge-cli/master/dist/forge-cli.phar
$ sudo mv forge-cli.phar /usr/local/bin/forge

Once you have it installed, you can run forge list to see a list of available commands. At the time of this blog post, the output of forge list looks as follows:

Console Tool

Usage:
  [options] command [arguments]

Options:
  --help           -h Display this help message.
  --quiet          -q Do not output any message.
  --verbose        -v|vv|vvv Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
  --version        -V Display this application version.
  --ansi              Force ANSI output.
  --no-ansi           Disable ANSI output.
  --no-interaction -n Do not ask any interactive question.

Available commands:
  env          Get a list of Environment Variables
  help         Displays help for a command
  list         Lists commands
  sites        List the sites configured by Forge
log
  log:deploy   Get the latest deploy log
  log:job      Get the latest log for a scheduled job

To get more details about a particular command, run forge help [command_name]. For example, the help for the env command looks like this:

Usage:
 env site [environment]

Arguments:
 site                  Which site would you like to check for? i.e. test.com
 environment           Which environment would you like to check for?

Options:
 --help (-h)           Display this help message.
 --quiet (-q)          Do not output any message.
 --verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
 --version (-V)        Display this application version.
 --ansi                Force ANSI output.
 --no-ansi             Disable ANSI output.
 --no-interaction (-n) Do not ask any interactive question.

The Forge-CLI was born out of the desire to have a more streamlined access to Forge deploy logs, scripts, and environment variables. I plan to continue maintaining it, as well as add new features over time. Taylor Otwell seemed interested in the idea, and I hope that he might find it useful enough to install it on all newly created Forge servers by default.

If you have any feature requests, please feel free to submit an Issue on GitHub, or comment on this article. I'd love to hear what you think!