Giter Site home page Giter Site logo

blacksmith's Introduction

Blacksmith - The unofficial Laravel Forge PHP API

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 protected]');

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.

blacksmith's People

Contributors

mpociot avatar petericebear avatar djekl avatar leevigraham avatar

Watchers

James Cloos avatar Kishore Chandra Sahoo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.