Skip to content

πŸ”₯ A command line utility to interact with your Laravel Forge servers, sites, and more.

License

Notifications You must be signed in to change notification settings

suenert/forge-cli

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

forge-cli

Forge CLI

Latest Version on Packagist Total Downloads Software License Build Status StyleCI

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.

Table of Contents

Installation

Via composer:

$ composer global require sven/forge-cli

Setup

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.

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).

Usage

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}.


Servers

list:servers

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:server

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:16

make:server

Create 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:server

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:server

Reboot one of your servers. You will need to confirm your action.

$ forge reboot:server {serverId}

delete:server

Delete an existing server. You will need to confirm your action.

$ forge delete:server {serverId}

Sites

list:sites

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:site

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:19

make:site

Create a new site on one of your servers.

$ forge make:site {serverId} 
    --domain=example.com
    --type=php
    --directory=/public

update:site

Update a site on a specified server.

$ forge update:site {serverId} {siteId}
    --directory=/html

delete:site

Delete a site. You will need to confirm your action.

$ forge delete:site {serverId} {siteId}

Services

reboot:service

Reboot a service on the given server. Supported services are nginx, mysql, and postgres.

$ forge reboot:service {serverId} {service}

stop:service

Stop a service on the given server. Supported services are nginx, mysql, and postgres.

$ forge stop:service {serverId} {service}

install: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_TOKEN

uninstall:service

Uninstall a service from the given server. Supported services are blackfire and papertrail.

$ forge uninstall:service {serverId} {service}

Daemons

list:daemons

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:daemon

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

make:daemon

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:daemon

Reboot the given daemon. You will need to confirm your action.

$ forge reboot:daemon {serverId} {daemonId}

delete:daemon

Delete the given daemon from the given server. You will need to confirm your action.

$ forge delete:daemon {serverId} {daemonId}

Firewall Rules

make:rule

Create a new firewall rule.

$ forge make:rule {serverId}
    --name="firewall rule"
    --port=88

list:rules

Show all firewall rules.

$ forge list:rules {serverId}

show:rule

Show information about one of your firewall rules.

$ forge show:rule {serverId} {ruleId}

delete:rule

Delete a given firewall rule from one of your servers. You will need to confirm your action.

$ forge delete:rule {serverId} {ruleId}

Scheduled Jobs

make:job

Create a new scheduled job.

$ forge make:job {serverId}
    --command="echo 'hello world' > /dev/null"
    --frequency="hourly"

list:jobs

Show all scheduled jobs.

$ forge list:jobs {serverId}

show:job

Show information about one of your scheduled jobs.

$ forge show:job {serverId} {jobId}

delete:job

Delete a given scheduled job from one of your servers. You will need to confirm your action.

$ forge delete:job {serverId} {jobId}

Databases

make:database

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"

list:databases

Show all databases on a server.

$ forge list:databases {serverId}

show:database

Show information about one of your databases.

$ forge show:database {serverId} {databaseId}

delete:database

Delete a given database from one of your servers. You will need to confirm your action.

$ forge delete:database {serverId} {databaseId}

SSL Certificates

list:certificates

Show all certificates installed on the given site.

$ forge list:certificates {serverId} {siteId}

show:certificate

Show information about the specified certificate.

$ forge show:certificate {serverId} {siteId} {certificateId}

make:certificate

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:certificate

Activate a currently installed SSL certificate.

$ forge activate:certificate {serverId} {siteId} {certificateId}

install:certificate

Install a certificate on the given site.

$ forge install:certificate {serverId} {siteId} {certificateId}

delete:certificate

Revoke and remove a certificate from the given site. You will need to confirm you action.

$ forge delete:certificate {serverId} {siteId} {certificateId}

SSH Keys

make:key

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.pub

list:keys

Show all SSH keys installed on a server.

$ forge list:keys {serverId}

show:key

Show information about one of your SSH keys.

$ forge show:key {serverId} {keyId}

delete:key

Delete a given SSH key from one of your servers. You will need to confirm your action.

$ forge delete:key {serverId} {keyId}

Workers

make:worker

Create a new worker.

$ forge make:worker {serverId} {siteId}
    --connection=sqs
    --timeout=90
    --sleep=10
    --tries=1
    --daemon

list:workers

Show all workers installed on a site.

$ forge list:workers {serverId} {siteId}

show:worker

Show information about one of your workers.

$ forge show:worker {serverId} {siteId} {workerId}

delete:worker

Delete a given worker from one of your sites. You will need to confirm your action.

$ forge delete:worker {serverId} {siteId} {workerId}

reboot:worker

Reboot one of your workers. You will need to confirm your action.

$ forge reboot:worker {serverId} {siteId} {workerId}

Deployment

deploy:site

Deploy the given site.

$ forge deploy:site {serverId} {siteId}

enable:quickdeploy

Enable quick deployment for the given site.

$ forge enable:quickdeploy {serverId} {siteId}

disable:quickdeploy

Disable quick deployment for the given site.

$ forge disable:quickdeploy {serverId} {siteId}

get:deploy-script

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.txt

update:deploy-script

Update the deployment script of the given site.

$ forge update:deploy-script {serverId} {siteId}
    --file=file.txt

If you do not supply the --file option, the command will look in STDIN for any input:

$ forge update:deploy-script {serverId} {siteId} < file.txt

get:deploy-log

Show 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.log

reset:deploy-state

Reset the state of the deployment.

$ forge reset:deploy-state {serverId} {siteId}

Configuration

get:env

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.txt

update:env

Update the environment file for one of your sites.

$ forge update:env {serverId} {siteId}
    --file=new-env.txt

If you do not supply the --file option, the command will look in STDIN for any input:

$ forge update:env {serverId} {siteId} < new-env.txt

get:nginx-config

Get 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.conf

update:nginx-config

Update the nginx config file for one of your sites.

$ forge update:nginx-config {serverId} {siteId}
    --file=new.conf

If you do not supply the --file option, the command will look in STDIN for any input:

$ forge update:nginx-config {serverId} {siteId} < new.conf

Projects

install:git

Install 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.

delete:git

Remove a git project from the given site. You will need to confirm your action.

$ forge delete:git {serverId} {siteId}

install:wordpress

Install WordPress on the given site.

$ forge install:wordpress {serverId} {siteId}
    --database="name_of_database"
    --user="your_username"

remove:wordpress

Remove a WordPress project from the given site. You will need to confirm your action.

$ forge delete:wordpress {serverId} {siteId}

Recipes

make:recipe

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.txt

list:recipes

Show all recipes in your Forge account.

$ forge list:recipes

show:recipe

Show information about one of your recipes.

$ forge show:recipe {recipeId}

run:recipe

Run the given recipe on the specified server(s).

$ forge run:recipe {recipeId}
    --server=1234
    --server=5678

delete:recipe

Delete the given recipe. You will need to confirm your action.

$ forge delete:recipe {recipeId}

Credentials

Show all credentials associated with your account.

$ forge credentials

+-------+----------+--------+
| Id    | Name     | Type   |
+-------+----------+--------+
| 15071 | Personal | ocean2 |
+-------+----------+--------+

Contributing

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.

License

sven/forge-cli is licensed under the MIT License (MIT). Please see the license file for more information.

About

πŸ”₯ A command line utility to interact with your Laravel Forge servers, sites, and more.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%