This package is abandoned: Use the official laravel/forge-cli
instead.
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-cli
Ensure 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 authorize
When prompted for it, paste in your API key. You may optionally pass in the key directly as an argument to the command:
$ forge authorize <your_key_here>
If the API key on your Forge account changed, you'll need to run the same command again. A hidden 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 server:list
+----------------+--------+----------------+-------------+-------+
| Name | Id | IP Address | Region | Ready |
+----------------+--------+----------------+-------------+-------+
| sparkling-reef | 124833 | 95.85.60.157 | Amsterdam 2 | Yes |
+----------------+--------+----------------+-------------+-------+
Show information about one of your servers.
$ forge server:show {serverId}
Name: sparkling-reef
IP Address: 95.85.60.157
Size: 512MB
Region: Amsterdam 2
PHP version: php71
Created: 2017-03-13 20:59:16
Create a new server.
$ forge server:make
--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 server:update {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 server:reboot {serverId}
Delete an existing server. You will need to confirm your action.
$ forge server:delete {serverId}
Show all sites installed on a server.
$ forge site:list {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 site:show {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:19
Create a new site on one of your servers. Use --alias
to include one or more additional domains.
$ forge site:make {serverId}
--domain=example.com
--alias=example.org
--alias=another-site.net
--type=php
--directory=/public
Update a site on a specified server.
$ forge site:update {serverId} {siteId}
--directory=/html
Deploy the given site.
$ forge site:deploy {serverId} {siteId}
Delete a site. You will need to confirm your action.
$ forge site:delete {serverId} {siteId}
Reboot a service on the given server. Supported services are nginx
, mysql
, and postgres
.
$ forge service:reboot {serverId} {service}
Stop a service on the given server. Supported services are nginx
, mysql
, and postgres
.
$ forge service:stop {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 service:install {serverId} {service}
--host=192.168.1.1
--server-id=12345
--server-token=YOUR_SERVER_TOKEN
Uninstall a service from the given server. Supported services are blackfire
and papertrail
.
$ forge service:uninstall {serverId} {service}
List all active daemons on the given server.
$ forge daemon:list {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:33
Create 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=root
Reboot 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 MySQL user with access to the given databases.
$ forge mysql-user:make {serverId}
--username="your_username"
--password="password"
--database=456
--database=789
List all MySQL users on the given server.
$ forge mysql-user:list {serverId}
+-------+---------------+------------+---------------------+
| Id | Name | Status | Created |
+-------+---------------+------------+---------------------+
| 67890 | your_username | installing | 2017-03-13 21:14:19 |
+-------+---------------+------------+---------------------+
Show information about the given MySQL user.
$ forge mysql-user:show {serverId} {userId}
Status: installing
Name: your_username
Created: 2017-03-21 18:26:33
Update the databases a MySQL user has access to.
$ forge mysql-user:update {serverId} {userId}
--database=987
--database=654
Delete the given MySQL user from your server. You will need to confirm your action.
$ forge mysql-user:delete {serverId} {userId}
Create a new firewall rule.
$ forge rule:make {serverId}
--name="firewall rule"
--port=88
Show all firewall rules.
$ forge rule:list {serverId}
Show information about one of your firewall rules.
$ forge rule:show {serverId} {ruleId}
Delete a given firewall rule from one of your servers. You will need to confirm your action.
$ forge rule:delete {serverId} {ruleId}
Create a new scheduled job.
$ forge job:make {serverId}
--user="forge"
--command="echo 'hello world' > /dev/null"
--frequency="hourly"
Show all scheduled jobs.
$ forge job:list {serverId}
Show information about one of your scheduled jobs.
$ forge job:show {serverId} {jobId}
Delete a given scheduled job from one of your servers. You will need to confirm your action.
$ forge job:delete {serverId} {jobId}
Create a new database. The flags --user
and --password
must either both be present or both
be absent.
$ forge database:make {serverId}
--user="sven"
--password="My_P45sw0rD"
Show all databases on a server.
$ forge database:list {serverId}
Show information about one of your databases.
$ forge database:show {serverId} {databaseId}
Delete a given database from one of your servers. You will need to confirm your action.
$ forge database:delete {serverId} {databaseId}
Show all certificates installed on the given site.
$ forge certificate:list {serverId} {siteId}
Show information about the specified certificate.
$ forge certificate:show {serverId} {siteId} {certificateId}
Create a new certificate for one of your sites.
$ forge certificate:make {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 certificate:activate {serverId} {siteId} {certificateId}
Install a certificate on the given site.
$ forge certificate:install {serverId} {siteId} {certificateId}
Revoke and remove a certificate from the given site. You will need to confirm you action.
$ forge certificate:delete {serverId} {siteId} {certificateId}
Create a new SSH key and add it to a server.
$ forge key:make {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 key:make {serverId} --name="Macbook" < ~/.ssh/id_rsa.pub
Show all SSH keys installed on a server.
$ forge key:list {serverId}
Show information about one of your SSH keys.
$ forge key:show {serverId} {keyId}
Delete a given SSH key from one of your servers. You will need to confirm your action.
$ forge key:delete {serverId} {keyId}
Create a new worker.
$ forge worker:make {serverId} {siteId}
--connection=sqs
--timeout=90
--sleep=10
--tries=1
--daemon
Show all workers installed on a site.
$ forge worker:list {serverId} {siteId}
Show information about one of your workers.
$ forge worker:show {serverId} {siteId} {workerId}
Delete a given worker from one of your sites. You will need to confirm your action.
$ forge worker:delete {serverId} {siteId} {workerId}
Reboot one of your workers. You will need to confirm your action.
$ forge worker:reboot {serverId} {siteId} {workerId}
Enable quick deployment for the given site.
$ forge quickdeploy:enable {serverId} {siteId}
Disable quick deployment for the given site.
$ forge quickdeploy:disable {serverId} {siteId}
Get the deployment script of the given site.
$ forge deploy-script:get {serverId} {siteId}
The output will be written to STDOUT
, so you can save it to a file directly:
$ forge deploy-script:get {serverId} {siteId} > file.txt
Update the deployment script of the given site.
$ forge deploy-script:set {serverId} {siteId}
--file=file.txt
If you do not supply the --file
option, the command will look in STDIN
for any input:
$ forge deploy-script:set {serverId} {siteId} < file.txt
Show the latest deployment log.
$ forge deploy-log {serverId} {siteId}
The output will be written to STDOUT
, so you can save it to a file directly:
$ forge deploy-log {serverId} {siteId} > file.log
Reset the state of the deployment.
$ forge reset-deploy-state {serverId} {siteId}
Get the environment file of one of your sites.
$ forge env:get {serverId} {siteId}
The output will be written to STDOUT
, so you can save it to a file directly:
$ forge env:get {serverId} {siteId} > env-file.txt
Update the environment file for one of your sites.
$ forge env:set {serverId} {siteId}
--file=new-env.txt
If you do not supply the --file
option, the command will look in STDIN
for any input:
$ forge env:set {serverId} {siteId} < new-env.txt
Get the nginx config file of one of your sites.
$ forge nginx-config:get {serverId} {siteId}
The output will be written to STDOUT
, so you can save it to a file directly:
$ forge nginx-config:get {serverId} {siteId} > nginx.conf
Update the nginx config file for one of your sites.
$ forge nginx-config:set {serverId} {siteId}
--file=new.conf
If you do not supply the --file
option, the command will look in STDIN
for any input:
$ forge nginx-config:set {serverId} {siteId} < new.conf
Install a git project on the given site.
$ forge git:install {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 git:delete {serverId} {siteId}
Install WordPress on the given site.
$ forge wordpress:install {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 wordpress:delete {serverId} {siteId}
Create a new recipe.
$ forge recipe:make
--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 recipe:make --name="My Recipe" --user=forge < file.txt
Show all recipes in your Forge account.
$ forge recipe:list
Show information about one of your recipes.
$ forge recipe:show {recipeId}
Run the given recipe on the specified server(s).
$ forge recipe:run {recipeId}
--server=1234
--server=5678
Delete the given recipe. You will need to confirm your action.
$ forge recipe:delete {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.