Interact with your Laravel Forge servers and sites via the command line with this package. Create and list servers, add sites, and install repositories all without leaving the comfort of your command line. An overview of all available commands can be found here.
Via composer:
$ composer global require sven/forge-cliEnsure Composer's global bin directory is included in your path. This directory is located at ~/.composer/vendor/bin on macOS / Linux, and at
%APPDATA%/Composer/vendor/bin on Windows.
Before using the commands, you have to provide an API token. To generate a new token, visit this page,
give the token a name (like ForgeCLI) and click "Create new token".
Then, execute the following command on the command line:
$ forge authorizeWhen prompted for it, paste in your API key.
If the API key on your Forge account changed, you'll need to run the same command again. The configuration file will be saved to your home
directory (~/forge.json on macOS / Linux, %USERPROFILE%/forge.json on Windows).
A list of commands with their explanation can be found below. You can also find a list of commands and their arguments by installing the package
and running forge list or forge help {command}.
Show all servers associated with your account.
$ forge list:servers
+----------------+--------+----------------+-------------+-------+
| Name | Id | IP Address | Region | Ready |
+----------------+--------+----------------+-------------+-------+
| sparkling-reef | 124833 | 95.85.60.157 | Amsterdam 2 | Yes |
+----------------+--------+----------------+-------------+-------+Show information about one of your servers.
$ forge show:server {serverId}
Name: sparkling-reef
IP Address: 95.85.60.157
Size: 512MB
Region: Amsterdam 2
PHP version: php71
Created: 2017-03-13 20:59:16Create a new server.
$ forge make:server
--provider=ocean2
--credentials={credentialId}
--region=ams2
--ip=127.0.0.1
--private-ip=192.168.1.1
--php=php71
--database=some_database
--install-maria
--load-balancer
--network={otherServerId}
--network={anotherServerId}Update the metadata on one of your servers. This will only update the data in Forge, it won't make any actual changes to your server.
$ forge update:server {serverId}
--name=sluggish-cheetah
--size=1GB
--ip=127.0.0.1
--private-ip=192.168.1.1
--max-upload-size=256
--network={otherServerId}
--network={anotherServerId} Reboot one of your servers. You will need to confirm your action.
$ forge reboot:server {serverId}Delete an existing server. You will need to confirm your action.
$ forge delete:server {serverId}Show all sites installed on a server.
$ forge list:sites {serverId}
+--------+-----------------+------+-----------------------------+--------+
| Id | Name | Type | Repository | Branch |
+--------+-----------------+------+-----------------------------+--------+
| 303243 | default | php | - | - |
| 303246 | svenluijten.com | html | svenluijten/svenluijten.com | master |
| 303247 | pkgst.co | php | svenluijten/slack-packagist | master |
+--------+-----------------+------+-----------------------------+--------+Show information about a site on a specified server.
$ forge show:site {serverId} {siteId}
Name: svenluijten.com
Repository info: svenluijten/svenluijten.com @ master
Directory: /build_production
Quick deploy: Off
Status: installed
Project type: html
Created: 2017-03-13 21:14:19Create a new site on one of your servers.
$ forge make:site {serverId}
--domain=example.com
--type=php
--directory=/publicUpdate a site on a specified server.
$ forge update:site {serverId} {siteId}
--directory=/htmlDelete a site. You will need to confirm your action.
$ forge delete:site {serverId} {siteId}Reboot a service on the given server. Supported services are nginx, mysql, and postgres.
$ forge reboot:service {serverId} {service}Stop a service on the given server. Supported services are nginx, mysql, and postgres.
$ forge stop:service {serverId} {service}Install a service on the given server. Supported services are blackfire and papertrail. The --host option
is only required when installing Papertrail, --server-id and --server-token are only required when installing
Blackfire.
$ forge install:service {serverId} {service}
--host=192.168.1.1
--server-id=12345
--server-token=YOUR_SERVER_TOKENUninstall a service from the given server. Supported services are blackfire and papertrail.
$ forge uninstall:service {serverId} {service}List all active daemons on the given server.
$ forge list:daemons {serverId}
+-------+------------+---------------------------------+---------------------+
| Id | Status | Command | Created |
+-------+------------+---------------------------------+---------------------+
| 12345 | installing | echo 'hello world' >> /dev/null | 2017-03-13 21:14:19 |
+-------+------------+---------------------------------+---------------------+Show information about the given daemon.
$ forge show:daemon {serverId} {daemonId}
Status: installing
Command: echo 'hello world' >> /dev/null
Created: 2017-03-21 18:26:33Create a new daemon to run on the given server. If no user is supplied, it defaults to forge.
$ forge make:daemon {serverId}
--command="command to run"
--user=rootReboot the given daemon. You will need to confirm your action.
$ forge reboot:daemon {serverId} {daemonId}Delete the given daemon from the given server. You will need to confirm your action.
$ forge delete:daemon {serverId} {daemonId}Create a new firewall rule.
$ forge make:rule {serverId}
--name="firewall rule"
--port=88Show all firewall rules.
$ forge list:rules {serverId}Show information about one of your firewall rules.
$ forge show:rule {serverId} {ruleId}Delete a given firewall rule from one of your servers. You will need to confirm your action.
$ forge delete:rule {serverId} {ruleId}Create a new scheduled job.
$ forge make:job {serverId}
--command="echo 'hello world' > /dev/null"
--frequency="hourly"Show all scheduled jobs.
$ forge list:jobs {serverId}Show information about one of your scheduled jobs.
$ forge show:job {serverId} {jobId}Delete a given scheduled job from one of your servers. You will need to confirm your action.
$ forge delete:job {serverId} {jobId}Create a new database. The flags --user and --password must either both be present or both
be absent.
$ forge make:database {serverId}
--user="sven"
--password="My_P45sw0rD"Show all databases on a server.
$ forge list:databases {serverId}Show information about one of your databases.
$ forge show:database {serverId} {databaseId}Delete a given database from one of your servers. You will need to confirm your action.
$ forge delete:database {serverId} {databaseId}Show all certificates installed on the given site.
$ forge list:certificates {serverId} {siteId}Show information about the specified certificate.
$ forge show:certificate {serverId} {siteId} {certificateId}Create a new certificate for one of your sites.
$ forge make:certificate {serverId} {siteId}
--domain="www.example.com"
--country="US"
--state="NY"
--city="New York"
--organization="Acme, Inc."
--department="Development"Activate a currently installed SSL certificate.
$ forge activate:certificate {serverId} {siteId} {certificateId}Install a certificate on the given site.
$ forge install:certificate {serverId} {siteId} {certificateId}Revoke and remove a certificate from the given site. You will need to confirm you action.
$ forge delete:certificate {serverId} {siteId} {certificateId}Create a new SSH key and add it to a server.
$ forge make:key {serverId}
--name="Macbook"
--file="~/.ssh/id_rsa.pub"If you do not supply the --file option, the command will look in STDIN for any input:
$ forge make:key {serverId} --name="Macbook" < ~/.ssh/id_rsa.pubShow all SSH keys installed on a server.
$ forge list:keys {serverId}Show information about one of your SSH keys.
$ forge show:key {serverId} {keyId}Delete a given SSH key from one of your servers. You will need to confirm your action.
$ forge delete:key {serverId} {keyId}Create a new worker.
$ forge make:worker {serverId} {siteId}
--connection=sqs
--timeout=90
--sleep=10
--tries=1
--daemonShow all workers installed on a site.
$ forge list:workers {serverId} {siteId}Show information about one of your workers.
$ forge show:worker {serverId} {siteId} {workerId}Delete a given worker from one of your sites. You will need to confirm your action.
$ forge delete:worker {serverId} {siteId} {workerId}Reboot one of your workers. You will need to confirm your action.
$ forge reboot:worker {serverId} {siteId} {workerId}Deploy the given site.
$ forge deploy:site {serverId} {siteId}Enable quick deployment for the given site.
$ forge enable:quickdeploy {serverId} {siteId}Disable quick deployment for the given site.
$ forge disable:quickdeploy {serverId} {siteId}Get the deployment script of the given site.
$ forge get:deploy-script {serverId} {siteId}The output will be written to STDOUT, so you can save it to a file directly:
$ forge get:deploy-script {serverId} {siteId} > file.txtUpdate the deployment script of the given site.
$ forge update:deploy-script {serverId} {siteId}
--file=file.txtIf you do not supply the --file option, the command will look in STDIN for any input:
$ forge update:deploy-script {serverId} {siteId} < file.txtShow the deployment log.
$ forge get:deploy-log {serverId} {siteId}The output will be written to STDOUT, so you can save it to a file directly:
$ forge get:deploy-log {serverId} {siteId} > file.logReset the state of the deployment.
$ forge reset:deploy-state {serverId} {siteId}Get the environment file of one of your sites.
$ forge get:env {serverId} {siteId}The output will be written to STDOUT, so you can save it to a file directly:
$ forge get:env {serverId} {siteId} > env-file.txtUpdate the environment file for one of your sites.
$ forge update:env {serverId} {siteId}
--file=new-env.txtIf you do not supply the --file option, the command will look in STDIN for any input:
$ forge update:env {serverId} {siteId} < new-env.txtGet the nginx config file of one of your sites.
$ forge get:nginx-config {serverId} {siteId}The output will be written to STDOUT, so you can save it to a file directly:
$ forge get:nginx-config {serverId} {siteId} > nginx.confUpdate the nginx config file for one of your sites.
$ forge update:nginx-config {serverId} {siteId}
--file=new.confIf you do not supply the --file option, the command will look in STDIN for any input:
$ forge update:nginx-config {serverId} {siteId} < new.confInstall a git project on the given site.
$ forge install:git {serverId} {siteId}
--provider="github"
--repository="username/repository"The provider option can be either github (default) or custom.
Remove a git project from the given site. You will need to confirm your action.
$ forge delete:git {serverId} {siteId}Install WordPress on the given site.
$ forge install:wordpress {serverId} {siteId}
--database="name_of_database"
--user="your_username"Remove a WordPress project from the given site. You will need to confirm your action.
$ forge delete:wordpress {serverId} {siteId}Create a new recipe.
$ forge make:recipe
--name="My Recipe"
--user=forge
--script="echo 'hi' >> /dev/null"If you do not supply the --script option, the command will look in STDIN for any input:
$ forge make:recipe --name="My Recipe" --user=forge < file.txtShow all recipes in your Forge account.
$ forge list:recipesShow information about one of your recipes.
$ forge show:recipe {recipeId}Run the given recipe on the specified server(s).
$ forge run:recipe {recipeId}
--server=1234
--server=5678Delete the given recipe. You will need to confirm your action.
$ forge delete:recipe {recipeId}Show all credentials associated with your account.
$ forge credentials
+-------+----------+--------+
| Id | Name | Type |
+-------+----------+--------+
| 15071 | Personal | ocean2 |
+-------+----------+--------+All contributions (pull requests, issues and feature requests) are welcome. Make sure to read through the CONTRIBUTING.md first, though. See the contributors page for all contributors.
sven/forge-cli is licensed under the MIT License (MIT). Please see the
license file for more information.
