mpociot/blacksmith

The unofficial Laravel Forge API

0.3.1 2016-11-21 12:50 UTC

This package is auto-updated.

Last update: 2021-05-24 03:04:08 UTC


README

Laravel Forge is awesome, right? Yes it is - but there's one thing it's missing - a proper API.

That's why this library exists - Blacksmith is an unofficial Laravel Forge API to automate common tasks.

The API is still improving and I will keep adding features, as I need them.

Getting Started

use Mpociot\Blacksmith\Blacksmith;

$blacksmith = new Blacksmith($email, $password);

Available methods

Get all active servers

Returns a Collection of Server objects.

$activeServers = $blacksmith->getActiveServers();

Get all sites for all servers

Returns a Collection of Site objects.

$sites = $blacksmith->getSites();

Get a server by its ID

Returns a single Server object.

$server = $blacksmith->getServer(1);

Add a server to Forge

Returns a single Server object with a provision url.

The following example will create a Load Balancer with a custom provider

$server = $blacksmith->addServer([
    'backups' => false,
    'database' => 'forge',
    'hhvm' => false,
    'ip_address' => '94.212.124.121',
    'maria' => false,
    'name' => 'harmonious-lagoon',
    'nodeBalancer' => true,
    'old_php' => false,
    'php_version' => 'php70',
    'private_ip_address' => '10.0.0.2',
    'provider' => 'custom',
    'size' => '2',
    'timezone' => 'Europe/Berlin',
]);

Get a site by its ID

Returns a single Site object.

$site = $blacksmith->getSite(1);

Get all circles

Returns a Collection of Circle objects of the user.

$circles = $blacksmith->getCircles();

Get a circle by its ID

Returns a single Circle object.

$circle = $blacksmith->getCircle(1);

Add a new circle

Returns a single Circle object.

$circle = $blacksmith->addCircle('Name of Circle');

Get all recipes

Returns a Collection of Recipe objects.

$recipes = $blacksmith->getRecipes();

Get a recipe by its ID

Returns a single Recipe object.

$recipe = $blacksmith->getRecipe(1);

Add a new recipe

Returns a single Recipe object.

$recipe = $blacksmith->addRecipe('RecipeName', 'root', 'Recipe contents');

Server methods

Get Sites

Returns a Collection of Site objects for the server.

$sites = $server->getSites();

Add a new site

Returns a the newly created Site object or throws an exception if errors occur.

$newSite = $server->addSite($site_name, $project_type = 'php', $directory = '/public', $wildcards = false);

Add a new SSH key

Add a SSH key to a server

$server->addSSHKey('Name SSH key', 'Contents of SSH key');

Remove a SSH key from a server

$server->removeSSHKey(1);

Update Metadata

Update the metadata of the current site, and return an updated Server object or throws an exception if errors occur.

$server = $server->updateMetadata($server_name, $ip_address, $private_ip_address, $size);

Get Schedules Jobs

Returns a Collection of ScheduledJob objects for the server.

$jobs = $server->getScheduledJobs();

Add a new scheduled job

Returns a the newly created ScheduledJob object or throws an exception if errors occur.

$newJob = $server->addScheduledJob($command, $user = 'forge', $frequency = 'minutely');

toArray

Returns an array containing all available server information.

$data = $server->toArray();

Site methods

Get Environment

Returns the configured .env file

$env_content = $site->getEnvironment();

Install an application

Install and deploy an application to the site.

$site->installApp($repository, $provider = 'github', $branch = 'master', $composer = true, $migrate = false);

Deploy an application

Deploys an application on this site.

$site->deploy();

Get last deployment log

Returns the last deployment log for this site.

$site->deployLog();

toArray

Returns an array containing all available site information.

$data = $site->toArray();

Circle methods

Invite a member by email

Returns a fresh Circle object or throws an exception if errors occur.

$circle = $circle->inviteMember('email@company.com');

Set all circle members

If you want to delete a member you update a circle with all member id's. It return a fresh Circle object.

$circle = $circle->setMembers([1,2]);

Set all circle servers

If you want to add or delete a server from the circle you update a circle with all server id's. It return a fresh Circle object.

$circle = $circle->setServers([1,2]);

Recipe methods

Update a Recipe

$recipe = $recipe->update($name, $user, $script);

License

Blacksmith is free software distributed under the terms of the MIT license.