PHPackages                             team-nifty-gmbh/forge-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. team-nifty-gmbh/forge-sdk

ActiveLibrary[API Development](/categories/api)

team-nifty-gmbh/forge-sdk
=========================

PHP SDK for forge RESTful API

0478[1 PRs](https://github.com/Team-Nifty-GmbH/forge-sdk/pulls)PHPCI failing

Since Nov 21Pushed 5mo agoCompare

[ Source](https://github.com/Team-Nifty-GmbH/forge-sdk)[ Packagist](https://packagist.org/packages/team-nifty-gmbh/forge-sdk)[ RSS](/packages/team-nifty-gmbh-forge-sdk/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

Laravel Forge SDK
=================

[](#laravel-forge-sdk)

A modern PHP SDK for the Laravel Forge API, built with Saloon v3.

Installation
------------

[](#installation)

```
composer require team-nifty/forge-sdk
```

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --provider="TeamNifty\Forge\ForgeServiceProvider"
```

Add your Forge API token to your `.env` file:

```
FORGE_API_TOKEN=your-api-token-here
FORGE_DEFAULT_ORGANIZATION=your-org-slug
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

The SDK provides a fluent interface for interacting with the Forge API:

```
use function TeamNifty\Forge\forge;

// Get all servers for an organization
$servers = forge()
    ->servers()
    ->organizationsServersIndexRequest(organization: 'team-nifty')
    ->json('data');

// Get a specific server
$server = forge()
    ->servers()
    ->organizationsServersShowRequest(
        organization: 'team-nifty',
        server: 12345
    )
    ->json('data');
```

### Available Methods

[](#available-methods)

All paginated requests support these convenient methods:

#### `send()` - Send the request and get the Response object

[](#send---send-the-request-and-get-the-response-object)

```
$response = forge()
    ->servers()
    ->organizationsServersIndexRequest(organization: 'team-nifty')
    ->send();

$statusCode = $response->status();
$headers = $response->headers();
```

#### `json()` - Get JSON response data

[](#json---get-json-response-data)

```
// Get all data
$data = forge()
    ->servers()
    ->organizationsServersIndexRequest(organization: 'team-nifty')
    ->json();

// Get specific key
$servers = forge()
    ->servers()
    ->organizationsServersIndexRequest(organization: 'team-nifty')
    ->json('data');
```

#### `collect()` - Get response as Laravel Collection

[](#collect---get-response-as-laravel-collection)

```
$servers = forge()
    ->servers()
    ->organizationsServersIndexRequest(organization: 'team-nifty')
    ->collect('data');

// Use Collection methods
$activeServers = $servers->filter(fn($server) => $server['status'] === 'active');
```

#### `paginate()` - Iterate through all pages automatically

[](#paginate---iterate-through-all-pages-automatically)

```
$paginator = forge()
    ->servers()
    ->organizationsServersIndexRequest(organization: 'team-nifty')
    ->paginate();

// Iterate through all pages
foreach ($paginator as $server) {
    echo $server['name'] . PHP_EOL;
}

// Or collect all results at once
$allServers = $paginator->collect();
```

### Pagination

[](#pagination)

The SDK automatically handles Forge's cursor-based pagination. All paginated endpoints implement the `Paginatable` interface:

```
// Automatically fetch all pages
$paginator = forge()
    ->sites()
    ->organizationsSitesIndexRequest(organization: 'team-nifty')
    ->paginate();

foreach ($paginator as $site) {
    // Process each site
    echo "Site: {$site['name']}\n";
}

// Get all items as a collection
$allSites = $paginator->collect();

// Get specific number of items
$firstTenSites = $paginator->take(10)->collect();
```

### Resource Examples

[](#resource-examples)

#### Servers

[](#servers)

```
// List all servers
$servers = forge()
    ->servers()
    ->organizationsServersIndexRequest(organization: 'team-nifty')
    ->json('data');

// Get server details
$server = forge()
    ->servers()
    ->organizationsServersShowRequest(
        organization: 'team-nifty',
        server: 12345
    )
    ->json('data');

// List server events
$events = forge()
    ->servers()
    ->organizationsServersEventsIndexRequest(
        organization: 'team-nifty',
        server: 12345
    )
    ->paginate()
    ->collect();
```

#### Sites

[](#sites)

```
// List all sites
$sites = forge()
    ->sites()
    ->organizationsSitesIndexRequest(organization: 'team-nifty')
    ->paginate()
    ->collect();

// List sites on a specific server
$sites = forge()
    ->sites()
    ->organizationsServersSitesIndexRequest(
        organization: 'team-nifty',
        server: 12345
    )
    ->json('data');

// Get site details
$site = forge()
    ->sites()
    ->organizationsServersSitesShowRequest(
        organization: 'team-nifty',
        server: 12345,
        site: 67890
    )
    ->json('data');
```

#### Deployments

[](#deployments)

```
// List deployments
$deployments = forge()
    ->deployments()
    ->organizationsServersSitesDeploymentsIndexRequest(
        organization: 'team-nifty',
        server: 12345,
        site: 67890
    )
    ->paginate()
    ->collect();

// Deploy a site
$deployment = forge()
    ->deployments()
    ->organizationsServersSitesDeploymentsStoreRequest(
        organization: 'team-nifty',
        server: 12345,
        site: 67890
    )
    ->send();
```

#### Databases

[](#databases)

```
// List database schemas
$schemas = forge()
    ->databases()
    ->organizationsServersDatabaseSchemasIndexRequest(
        organization: 'team-nifty',
        server: 12345
    )
    ->json('data');

// List database users
$users = forge()
    ->databases()
    ->organizationsServersDatabaseUsersIndexRequest(
        organization: 'team-nifty',
        server: 12345
    )
    ->paginate()
    ->collect();
```

#### Recipes

[](#recipes)

```
// List organization recipes
$recipes = forge()
    ->recipes()
    ->organizationsRecipesIndexRequest(organization: 'team-nifty')
    ->paginate()
    ->collect();

// List Forge-provided recipes
$forgeRecipes = forge()
    ->recipes()
    ->forgeRecipesIndexRequest()
    ->json('data');
```

### Filtering and Sorting

[](#filtering-and-sorting)

Many endpoints support filtering and sorting:

```
// Filter servers by name
$servers = forge()
    ->servers()
    ->organizationsServersIndexRequest(
        organization: 'team-nifty',
        filtername: 'production'
    )
    ->json('data');

// Sort servers by creation date (descending)
$servers = forge()
    ->servers()
    ->organizationsServersIndexRequest(
        organization: 'team-nifty',
        sort: '-created_at'
    )
    ->json('data');

// Combine filters and sorting
$servers = forge()
    ->servers()
    ->organizationsServersIndexRequest(
        organization: 'team-nifty',
        filterprovider: 'digitalocean',
        sort: 'name'
    )
    ->json('data');
```

### Error Handling

[](#error-handling)

The SDK uses Saloon's exception handling:

```
use Saloon\Exceptions\Request\FatalRequestException;
use Saloon\Exceptions\Request\ClientException;
use Saloon\Exceptions\Request\ServerException;

try {
    $servers = forge()
        ->servers()
        ->organizationsServersIndexRequest(organization: 'team-nifty')
        ->json('data');
} catch (ClientException $e) {
    // 4xx errors (client errors)
    echo "Client error: " . $e->getMessage();
    echo "Status: " . $e->getResponse()->status();
} catch (ServerException $e) {
    // 5xx errors (server errors)
    echo "Server error: " . $e->getMessage();
} catch (FatalRequestException $e) {
    // Connection errors, timeouts, etc.
    echo "Fatal error: " . $e->getMessage();
}
```

### Testing

[](#testing)

The SDK includes full support for testing with mocked responses:

```
use TeamNifty\Forge\Forge;
use Saloon\Laravel\Facades\Saloon;

// Mock all requests
Saloon::fake([
    '*' => Saloon::response(['data' => ['id' => 1, 'name' => 'Test Server']], 200),
]);

// Your test code
$server = forge()
    ->servers()
    ->organizationsServersShowRequest(
        organization: 'team-nifty',
        server: 1
    )
    ->json('data');

$this->assertEquals('Test Server', $server['name']);
```

Available Resources
-------------------

[](#available-resources)

The SDK provides access to all Forge API resources:

- **Organizations** - Manage organizations and credentials
- **Servers** - Server management and configuration
- **Sites** - Website and application management
- **Deployments** - Deployment management and webhooks
- **Databases** - Database and user management
- **Recipes** - Recipe management and execution
- **SSL Certificates** - SSL certificate management
- **Scheduled Jobs** - Cron job management
- **Daemons** - Background process management
- **Firewall Rules** - Firewall configuration
- **Security Rules** - Security rule management
- **Redirect Rules** - URL redirect management
- **Teams** - Team and member management
- **Roles** - Role and permission management
- **SSH Keys** - SSH key management
- **Providers** - Cloud provider information
- **Monitors** - Server monitoring
- **Nginx** - Nginx template management

Advanced Usage
--------------

[](#advanced-usage)

### Custom Base URL

[](#custom-base-url)

If you're using a custom Forge instance:

```
$forge = new Forge(
    bearerToken: 'your-token',
);

// The base URL is hardcoded to https://forge.laravel.com/api
// If you need a different base URL, you'll need to extend the Forge class
```

### OAuth Authentication

[](#oauth-authentication)

For OAuth-based authentication:

```
$forge = new Forge(
    bearerToken: 'your-access-token',
    clientId: 'your-client-id',
    clientSecret: 'your-client-secret',
);
```

### Request Customization

[](#request-customization)

You can customize individual requests:

```
$response = forge()
    ->servers()
    ->organizationsServersIndexRequest(organization: 'team-nifty')
    ->send()
    ->throw(); // Throw exception on error

// Access raw response
$json = $response->body();
$array = $response->json();
$status = $response->status();
```

Requirements
------------

[](#requirements)

- PHP 8.2 or higher
- Laravel 11 or higher

License
-------

[](#license)

This package is open-sourced software licensed under the MIT license.

Credits
-------

[](#credits)

Built with [Saloon](https://docs.saloon.dev/) by Sammyjo20.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance48

Moderate activity, may be stable

Popularity17

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/315f809551baee16f7c5531f89a864b4d5b59bde8882779c30d4a01ae36e718e?d=identicon)[team-nifty](/maintainers/team-nifty)

---

Top Contributors

[![patrickweh](https://avatars.githubusercontent.com/u/40495041?v=4)](https://github.com/patrickweh "patrickweh (3 commits)")

### Embed Badge

![Health badge](/badges/team-nifty-gmbh-forge-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/team-nifty-gmbh-forge-sdk/health.svg)](https://phpackages.com/packages/team-nifty-gmbh-forge-sdk)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
