Download the PHP package artisan-build/forge-client without Composer

On this page you can find all versions of the php package artisan-build/forge-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package forge-client

Artisan Build Forge Client Logo

Laravel Forge Client

A comprehensive, production-ready PHP SDK for the Laravel Forge API. Built with Saloon, this package provides a clean, strongly-typed interface for managing your Laravel Forge infrastructure programmatically.

[!WARNING] This package is currently under active development. Once a 0.* version has been tagged, we strongly recommend locking your application to a specific working version because we might make breaking changes even in patch releases until we've tagged 1.0.

Features

Table of Contents

Installation

Install the package via Composer:

Publish Configuration (Optional)

The package works out of the box, but you can publish the configuration file to customize settings:

This creates config/forge-client.php where you can configure API settings, logging, retry behavior, and defaults.

Configuration

Environment Variables

Set your Forge API token in your .env file:

You can generate an API token from your Forge account settings.

Optional Configuration

Default Organization & Server

Setting default organization and server in your configuration simplifies commands:

With defaults configured, you can run commands without specifying organization/server:

Argument Ordering Principle

All commands follow a consistent argument ordering pattern: most specific โ†’ least specific.

This means resource-specific identifiers always come before broader context arguments:

This pattern makes commands intuitive and predictable across all resources. When both organization and server can have config defaults, the more specific resource (server) is still specified before the broader context (organization).

Quick Start

Using the SDK in Your Code

Using Artisan Commands

Basic Usage

Organizations

Organizations are the top-level entity in Forge. All servers, sites, and resources belong to an organization.

List Organizations

Artisan Command:

Get Organization Details

Artisan Command:

Servers

Servers are the core infrastructure managed by Forge.

List Servers

Artisan Command:

Get Server Details

Artisan Command:

Create a Server

Artisan Command:

Available Enums:

Reboot a Server

Artisan Command:

Delete a Server

Artisan Command:

Sites

Sites represent the web applications hosted on your servers.

List Sites

Artisan Command:

Get Site Details

Artisan Command:

Create a Site

Artisan Command:

Update Site

Artisan Command:

Deploy Site

Artisan Command:

Enable/Disable Quick Deploy

Artisan Commands:

Delete Site

Artisan Command:

Deployments

Monitor and manage site deployments.

List Deployments

Artisan Command:

Get Deployment Details

Artisan Command:

Trigger Deployment

Artisan Command:

Update Deployment Script

Artisan Command:

Databases

Manage MySQL/PostgreSQL databases and users.

List Database Schemas

Artisan Command:

Get Database Details

Artisan Command:

Create Database

Artisan Command:

Delete Database

Artisan Command:

List Database Users

Artisan Command:

Create Database User

Artisan Command:

Update Database User

Artisan Command:

Delete Database User

Artisan Command:

Background Processes

Manage background processes (daemons) running on your servers.

List Background Processes

Artisan Command:

Get Background Process Details

Artisan Command:

Create Background Process

Artisan Command:

Update Background Process

Artisan Command:

Restart Background Process

Artisan Command:

Delete Background Process

Artisan Command:

Firewall Rules

Manage server firewall rules for security.

List Firewall Rules

Artisan Command:

Get Firewall Rule Details

Artisan Command:

Create Firewall Rule

Artisan Command:

Firewall Rule Types:

Delete Firewall Rule

Artisan Command:

SSL Certificates

Manage SSL certificates for your sites.

List SSL Certificates

Artisan Command:

Get SSL Certificate Details

Artisan Command:

Create SSL Certificate

Artisan Command:

Activate SSL Certificate

Artisan Command:

Delete SSL Certificate

Artisan Command:

Commands

The Commands resource represents one-off commands executed on servers (not to be confused with Artisan commands).

Scheduled Jobs

Manage cron jobs on your servers.

Other Resources

The SDK provides full access to all Forge API resources:

All resources follow the same pattern as shown above. Check the resource classes in src/Resource/ for available methods.

Artisan Commands Reference

All commands support the --dangerously-skip-confirmation flag to bypass confirmation prompts for automation.

Organization Commands

List Organizations

Options:

Get Organization

Arguments:

Example:

Server Credential Commands

List Server Credentials

Arguments:

Options:

Example:

This command lists all server credentials (cloud provider API keys) configured for your organization. You'll need the credential ID when creating servers.

Provider Commands

List Providers

Options:

Example:

List Provider Regions

Arguments:

Options:

Example:

List Provider Sizes

Arguments:

Options:

Example:

Server Commands

List Servers

Options:

Example:

Get Server

Arguments:

Options:

Example:

Create Server

Options:

Prerequisites: Before creating a server, you need to:

  1. Get a credential ID: php artisan forge:list-server-credentials --organization=my-org
  2. Get a provider ID: php artisan forge:list-providers
  3. Get a region code: php artisan forge:list-provider-regions {provider-id}
  4. Get a size ID: php artisan forge:list-provider-sizes {provider-id}

Example:

Reboot Server

Arguments:

Options:

Example:

Destroy Server

Arguments:

Options:

Example:

Site Commands

List Sites

Options:

Get Site

Arguments:

Options:

Create Site

Options:

Example:

Update Site

Arguments:

Options:

Deploy Site

Arguments:

Options:

Example:

Enable Quick Deploy

Arguments:

Options:

Disable Quick Deploy

Arguments:

Options:

Destroy Site

Arguments:

Options:

Deployment Commands

List Deployments

Arguments:

Options:

Get Deployment

Arguments:

Options:

Trigger Deployment

Arguments:

Options:

Update Deployment Script

Arguments:

Options:

Example:

Database Commands

List Databases

Options:

Get Database

Arguments:

Options:

Create Database

Options:

Example:

Destroy Database

Arguments:

Options:

List Database Users

Options:

Get Database User

Arguments:

Options:

Create Database User

Options:

Example:

Update Database User

Arguments:

Options:

Destroy Database User

Arguments:

Options:

Background Process Commands

List Background Processes

Options:

Get Background Process

Arguments:

Options:

Create Background Process

Options:

Example:

Update Background Process

Arguments:

Options:

Restart Background Process

php artisan forge:restart-background-process {process}

Arguments:

Options:

Destroy Background Process

php artisan forge:destroy-background-process {process}

Arguments:

Options:

Firewall Commands

List Firewall Rules

php artisan forge:list-firewall-rules

Options:

Get Firewall Rule

php artisan forge:get-firewall-rule {rule}

Arguments:

Options:

Create Firewall Rule

php artisan forge:create-firewall-rule

Options:

Example:

php artisan forge:create-firewall-rule \
  --organization=my-org \
  --server=production-server \
  --name="Allow Redis from app server" \
  --port=6379 \
  --type=allow \
  --ip-address=192.168.1.100

Destroy Firewall Rule

php artisan forge:destroy-firewall-rule {rule}

Arguments:

Options:

SSL Certificate Commands

List SSL Certificates

php artisan forge:list-ssl-certificates {site}

Arguments:

Options:

Get SSL Certificate

php artisan forge:get-ssl-certificate {certificate}

Arguments:

Options:

Create SSL Certificate

php artisan forge:create-ssl-certificate {site}

Arguments:

Options:

Example:

# Let's Encrypt
php artisan forge:create-ssl-certificate example.com \
  --organization=my-org \
  --server=production-server \
  --domain=example.com \
  --type=letsencrypt

# Existing certificate
php artisan forge:create-ssl-certificate example.com \
  --organization=my-org \
  --server=production-server \
  --type=existing \
  --certificate="$(cat /path/to/certificate.crt)" \
  --key="$(cat /path/to/private.key)"

Activate SSL Certificate

php artisan forge:activate-ssl-certificate {certificate}

Arguments:

Options:

Destroy SSL Certificate

php artisan forge:destroy-ssl-certificate {certificate}

Arguments:

Options:

Enums

The SDK provides strongly-typed enums for all Forge API values, ensuring type safety and preventing invalid API requests.

Available Enums

CloudProvider

Helper Methods:

ServerType

DatabaseType

Helper Methods:

PhpVersion

Helper Methods:

UbuntuVersion

Helper Methods:

FirewallRuleType

CertificateType

SiteType

IntegrationType

JobFrequency

LogType

MonitorType

Using Enums

Enums provide type safety and validation:

Error Handling

The SDK provides comprehensive exception handling with detailed error messages.

Exception Types

ForgeException

Base exception for all Forge Client errors.

Methods:

ValidationException

Thrown when request parameters fail validation before the API call.

Methods:

ApiException

Thrown when the Forge API returns an error response.

Methods:

AuthenticationException

Thrown when API authentication fails.

RateLimitException

Thrown when Forge API rate limit is exceeded (60 requests per minute).

Methods:

Error Handling Patterns

Comprehensive Try-Catch

Laravel Exception Handler

Add to app/Exceptions/Handler.php:

Troubleshooting

Common Issues

Authentication Failures

Problem: AuthenticationException: Invalid API token

Solutions:

  1. Verify your API token in .env:
    FORGE_API_TOKEN=your-actual-token
  2. Generate a new token at https://forge.laravel.com/user-profile/api
  3. Ensure the token has required permissions (full access recommended)
  4. Check the token wasn't revoked in Forge dashboard

Rate Limiting

Problem: RateLimitException: Too many requests

Details: Forge API limits requests to 60 per minute per API token.

Solutions:

  1. Implement request throttling in your application:

  2. Batch operations when possible
  3. Cache Forge data locally to reduce API calls
  4. Use webhooks for real-time updates instead of polling

Server/Site Not Found

Problem: ApiException: Server not found (404)

Solutions:

  1. Verify the server ID is correct
  2. Check you're using the correct organization
  3. Ensure the server wasn't deleted
  4. If using server name, ensure it's unique:

    # This might fail if multiple servers named "staging"
    php artisan forge:get-server staging
    
    # Use ID instead
    php artisan forge:get-server 12345

Command Failures

Problem: Artisan commands hang or fail

Solutions:

  1. Ensure defaults are configured if not passing arguments:

    FORGE_ORGANIZATION=my-org
    FORGE_SERVER=my-server
  2. Check command syntax:

    # Incorrect
    php artisan forge:create-server my-server
    
    # Correct
    php artisan forge:create-server \
     --name=my-server \
     --organization=my-org \
     --provider=ocean2 \
     --credential=123 \
     --size=456 \
     --region=nyc3
  3. Use --help to see required options:
    php artisan forge:create-server --help

Logging Issues

Problem: No logs appearing for Forge operations

Solutions:

  1. Check logging configuration:

    FORGE_LOG_CHANNEL=stack
    FORGE_LOG_LEVEL=info
  2. Ensure log channel exists in config/logging.php

  3. Verify log permissions:
    chmod -R 775 storage/logs

SSL Certificate Errors

Problem: Let's Encrypt certificate creation fails

Solutions:

  1. Verify domain DNS points to server
  2. Ensure site is accessible via HTTP first
  3. Check firewall allows ports 80 and 443
  4. Domain must be publicly accessible (no local/private IPs)

Network/Timeout Issues

Problem: Requests timing out

Solutions:

  1. Increase timeout in config:

    FORGE_TIMEOUT=60
  2. Check network connectivity:

    curl -I https://forge.laravel.com/api
  3. Verify no firewall blocking outbound HTTPS

Debug Mode

Enable detailed logging for troubleshooting:

Getting Help

Contributing

This package is part of our internal toolkit and is optimized for our own purposes. We do not accept issues or PRs in this repository.

However, if you find this package useful and want to build upon it for your own needs, you're welcome to fork it!

License

The MIT License (MIT). Please see License File for more information.


All versions of forge-client with dependencies

PHP Build Version
Package Version
Requires illuminate/support Version ^11.36|^12.0|^13.0
saloonphp/laravel-plugin Version ^4.0
saloonphp/saloon Version ^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package artisan-build/forge-client contains the following files

Loading the files please wait ...