Laravel Forge PHP SDK

News

April 4th, 2017

forge-api.png

Laravel Forge announced it’s first official API back in February and we have seen a lot of interesting uses like the F-Bar Mac app. Today, Mohamed Said released a PHP SDK for the API that covers all the features.

Here is an example of creating a new server with this SDK:

1$server = $forge->createServer([
2 "provider"=> "ocean2",
3 "credential_id"=> 1,
4 "name"=> "test-via-api",
5 "size"=> "512MB",
6 "database"=> "test123",
7 "php_version"=> "php71",
8 "region"=> "ams2"
9]);

Of course, it also allows you to do much more and it works with the familiar Laravel expressive syntax. As an example take a look at more of the server commands available:

1$server->update(array $data)
2$server->delete()
3$server->revokeAccess()
4$server->reconnect()
5$server->reactivate()
6$server->rebootMysql()
7$server->stopMysql()
8$server->rebootPostgres()
9$server->stopPostgres()
10$server->rebootNginx()
11$server->stopNginx()
12$server->installBlackfire(array $data)
13$server->removeBlackfire()
14$server->installPapertrail(array $data)
15$server->removePapertrail()

The SDK is freely available under the MIT license and it’s available on Github. The readme includes plenty of examples and explanation for working with the SDK.

Filed in:

Eric L. Barnes

Eric is the creator of Laravel News and has been covering Laravel since 2012.