PHPackages                             augusl/zenlayercloud-laravel-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. augusl/zenlayercloud-laravel-sdk

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

augusl/zenlayercloud-laravel-sdk
================================

Laravel SDK for Zenlayer Cloud — Virtual Machine (VM) and Elastic Compute (ZEC) services.

v0.1.0(3w ago)01Apache-2.0PHPPHP ^8.2CI passing

Since May 13Pushed 3w agoCompare

[ Source](https://github.com/augusl/zenlayercloud-sdk-laravel)[ Packagist](https://packagist.org/packages/augusl/zenlayercloud-laravel-sdk)[ Docs](https://github.com/augusl/zenlayercloud-sdk-laravel)[ RSS](/packages/augusl-zenlayercloud-laravel-sdk/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (9)Versions (2)Used By (0)

Zenlayer Cloud Laravel SDK
==========================

[](#zenlayer-cloud-laravel-sdk)

[![tests](https://github.com/augusl/zenlayercloud-sdk-laravel/actions/workflows/tests.yml/badge.svg)](https://github.com/augusl/zenlayercloud-sdk-laravel/actions/workflows/tests.yml)[![License](https://camo.githubusercontent.com/798509b4df525f56802b56f8096862487f08023e3d7561c68656f8dab10d0d6e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4170616368652d2d322e302d626c75652e737667)](LICENSE)![PHP](https://camo.githubusercontent.com/38db6e59e2b3b5169bd1aba5ff029b639e6246a3e64d07f8821c954a1202c3eb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e322d3737374242342e737667)![Laravel](https://camo.githubusercontent.com/5a05d3c9e420ab83f0af27d4cb7896ba703a8a6a7f0ad26ef6af052c8517b152/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d3131253230253743253230313225323025374325323031332d4646324432302e737667)

[中文文档](README-CN.md) · English

> **Unofficial, community-maintained SDK.** This package is **not** affiliated with or endorsed by Zenlayer Inc. It is built and maintained by community contributors against the public Zenlayer Cloud OpenAPI documentation. Bug reports and feature requests belong here; Zenlayer Cloud product questions belong on the [official documentation site](https://docs.console.zenlayer.com/api-reference/cn).

A first-class Laravel package for talking to [Zenlayer Cloud](https://www.zenlayer.com/)OpenAPI services. Designed to feel native — service providers, facades, configurable connections, the standard `Illuminate\Http\Client` for transport, and `Http::fake()` support out of the box.

The `v0.1.x` line covers the **Compute** product group:

- **Virtual Machine (VM)** — API version `2026-04-01`, 61 actions.
- **Elastic Compute (ZEC)** — API version `2025-09-01`, 197 actions.

Every Zenlayer Cloud Action is exposed as a typed PHP method backed by typed Request and Response model classes, so IDEs autocomplete the entire surface area.

---

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

[](#requirements)

ComponentVersionPHP`^8.2`Laravel`11.x` · `12.x` · `13.x``ext-json`enabled (default)`ext-hash`enabled (default)Installation
------------

[](#installation)

```
composer require augusl/zenlayercloud-laravel-sdk
```

Publish the configuration file:

```
php artisan vendor:publish --tag=zenlayercloud-config
```

Set credentials in your `.env`:

```
ZENLAYER_SECRET_KEY_ID=AKID-your-key-id
ZENLAYER_SECRET_KEY_PASSWORD=your-secret-key-password
```

The package supports Laravel's auto-discovery — the service provider and the `ZenlayerCloud` facade are registered for you.

---

Quick start
-----------

[](#quick-start)

### Resolve clients

[](#resolve-clients)

There are three equivalent ways to obtain a client:

```
use ZenlayerCloud\Laravel\Facades\ZenlayerCloud;
use ZenlayerCloud\Laravel\Vm\V20260401\VmClient;
use ZenlayerCloud\Laravel\Zec\V20250901\ZecClient;

// 1. Facade
$vm = ZenlayerCloud::vm();

// 2. Container resolution (defaults to the 'default' connection)
$vm = app(VmClient::class);

// 3. Constructor injection
public function __construct(private VmClient $vm) {}
```

### List availability zones

[](#list-availability-zones)

```
use ZenlayerCloud\Laravel\Facades\ZenlayerCloud;
use ZenlayerCloud\Laravel\Vm\V20260401\Models\DescribeZonesRequest;

$response = ZenlayerCloud::vm()->DescribeZones(new DescribeZonesRequest());

foreach ($response->response->zoneSet as $zone) {
    echo $zone->zoneId, ' ', $zone->zoneName, PHP_EOL;
}
```

### Create a virtual machine

[](#create-a-virtual-machine)

```
use ZenlayerCloud\Laravel\Facades\ZenlayerCloud;
use ZenlayerCloud\Laravel\Vm\V20260401\Models\ChargePrepaid;
use ZenlayerCloud\Laravel\Vm\V20260401\Models\CreateInstancesRequest;
use ZenlayerCloud\Laravel\Vm\V20260401\Models\SystemDisk;

$req                                = new CreateInstancesRequest();
$req->zoneId                        = 'SEL-A';
$req->imageId                       = 'IMG-xxxx';
$req->instanceType                  = 'S8I';
$req->instanceCount                 = 1;
$req->instanceChargeType            = 'PREPAID';
$req->instanceChargePrepaid         = new ChargePrepaid();
$req->instanceChargePrepaid->period = 12;
$req->systemDisk                    = new SystemDisk();
$req->systemDisk->diskSize          = 50;

$resp = ZenlayerCloud::vm()->CreateInstances($req);

logger()->info('Order placed', [
    'order'     => $resp->response->orderNumber,
    'instances' => $resp->response->instanceIdSet ?? [],
]);
```

### Elastic Compute (ZEC)

[](#elastic-compute-zec)

```
use ZenlayerCloud\Laravel\Facades\ZenlayerCloud;
use ZenlayerCloud\Laravel\Zec\V20250901\Models\DescribeVpcsRequest;

$resp = ZenlayerCloud::zec()->DescribeVpcs(new DescribeVpcsRequest());

foreach ($resp->response->dataSet as $vpc) {
    echo $vpc->vpcId, PHP_EOL;
}
```

### Error handling

[](#error-handling)

Every transport- and API-level failure surfaces as one typed exception:

```
use ZenlayerCloud\Laravel\Common\Exception\ZenlayerCloudSdkException;

try {
    $resp = ZenlayerCloud::vm()->DescribeInstances(new DescribeInstancesRequest());
} catch (ZenlayerCloudSdkException $e) {
    report($e);
    abort(502, sprintf(
        'Zenlayer error %s (request %s): %s',
        $e->errorCode,
        $e->requestId ?? '-',
        $e->getMessage(),
    ));
}
```

The exception exposes `$e->errorCode` (e.g. `INVALID_PARAMETER`, `NETWORK_ERROR`, `CREDENTIAL_VALUE_MISSING`, `CONFIG_INVALID`) and `$e->requestId` for log correlation.

---

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

[](#configuration)

The published `config/zenlayercloud.php` file follows Laravel's "connection" convention used by the database, cache, and mail components:

```
return [
    'default' => env('ZENLAYER_CONNECTION', 'default'),

    'connections' => [
        'default' => [
            'secret_key_id'       => env('ZENLAYER_SECRET_KEY_ID'),
            'secret_key_password' => env('ZENLAYER_SECRET_KEY_PASSWORD'),
            'endpoint'            => env('ZENLAYER_ENDPOINT', 'console.zenlayer.com'),
            'scheme'              => env('ZENLAYER_SCHEME', 'https'),
            'timeout'             => (int) env('ZENLAYER_TIMEOUT', 60),
            'retry'               => (bool) env('ZENLAYER_RETRY', false),
            'retry_max'           => (int) env('ZENLAYER_RETRY_MAX', 3),
            'debug'               => (bool) env('ZENLAYER_DEBUG', false),
            'proxy'               => env('ZENLAYER_PROXY'),
            'request_client'      => env('ZENLAYER_REQUEST_CLIENT'),
        ],

        'staging' => [
            // a second account, used per-call: ZenlayerCloud::vm('staging')
        ],
    ],
];
```

Switch between connections with the optional argument to the manager:

```
ZenlayerCloud::vm();              // 'default'
ZenlayerCloud::vm('staging');     // named connection
ZenlayerCloud::zec('production'); // any name from the 'connections' map
```

---

Testing the SDK in your app
---------------------------

[](#testing-the-sdk-in-your-app)

The transport layer is built on `Illuminate\Http\Client`, so Laravel's built-in `Http::fake()` is the only thing you need to mock the API:

```
use Illuminate\Support\Facades\Http;
use ZenlayerCloud\Laravel\Facades\ZenlayerCloud;
use ZenlayerCloud\Laravel\Vm\V20260401\Models\DescribeZonesRequest;

Http::fake([
    'console.zenlayer.com/*' => Http::response([
        'requestId' => 'r-1',
        'response'  => [
            'requestId' => 'r-1',
            'zoneSet'   => [['zoneId' => 'SEL-A', 'zoneName' => 'Seoul A']],
        ],
    ], 200),
]);

$resp = ZenlayerCloud::vm()->DescribeZones(new DescribeZonesRequest());

self::assertSame('SEL-A', $resp->response->zoneSet[0]->zoneId);

Http::assertSent(fn ($r) => $r->header('x-zc-action')[0] === 'DescribeZones');
```

---

Conventions
-----------

[](#conventions)

- **Method names follow the upstream Action names (PascalCase)** — e.g. `DescribeInstances`, `CreateInstances`, `ModifyInstancesAttribute`. This keeps copy-paste from the Zenlayer Cloud API reference unambiguous. The shipped `pint.json` does not enforce PSR-12 camelCase on those generated client methods.
- **Models are plain data objects** — public typed nullable properties for every field on the Action's schema. Null fields are omitted from the JSON body sent over the wire.
- **Responses come in wrappers** — every Action returns a `XxxResponse` whose `requestId` lives at the top level and whose payload lives under `response`. Access fields via `$resp->response->...`.

---

Local development
-----------------

[](#local-development)

```
# Install dev dependencies
composer install

# Run the test suite (Orchestra Testbench + PHPUnit)
composer test

# Run code-style checks
composer lint
composer lint:fix

# Run static analysis
composer analyse

# Regenerate the client + model classes from the upstream schema
ZENLAYER_SCHEMA_SRC=/path/to/upstream/schema composer codegen
```

See [CONTRIBUTING.md](CONTRIBUTING.md) for the full contributor workflow.

---

Roadmap
-------

[](#roadmap)

The first release line (`v0.1.x`) covers VM + ZEC. Other Zenlayer Cloud product groups (BMC, CCS, Traffic, ZDNS, ZGA, ZLB, ZLS, ZOS, ZRM, etc.) are deferred to subsequent minor versions; contributions are welcome.

Security
--------

[](#security)

Found a vulnerability? Please follow the responsible-disclosure process described in [SECURITY.md](SECURITY.md) — do not file a public issue.

License
-------

[](#license)

Apache-2.0 — see [LICENSE](LICENSE).

Disclaimer
----------

[](#disclaimer)

This is an **unofficial, community-maintained** Laravel SDK. It is provided as-is, with no affiliation with, sponsorship from, or endorsement by Zenlayer Inc. or any of its subsidiaries. "Zenlayer" and "Zenlayer Cloud" are trademarks of their respective owners; this project uses those names solely to describe the upstream service it integrates with.

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance94

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 Bus Factor1

Top contributor holds 75% 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

27d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/47f026fa940f93fa71b9e19e0b575293365824649f2d4dd15a429179721b237e?d=identicon)[augusl](/maintainers/augusl)

---

Top Contributors

[![augusl](https://avatars.githubusercontent.com/u/25142251?v=4)](https://github.com/augusl "augusl (3 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")

---

Tags

laravelsdkcloudvmzeczenlayerzenlayercloud

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/augusl-zenlayercloud-laravel-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/augusl-zenlayercloud-laravel-sdk/health.svg)](https://phpackages.com/packages/augusl-zenlayercloud-laravel-sdk)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[laravel/socialite

Laravel wrapper around OAuth 1 &amp; OAuth 2 libraries.

5.7k104.3M822](/packages/laravel-socialite)[spatie/laravel-export

Create a static site bundle from a Laravel app

670139.5k6](/packages/spatie-laravel-export)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

76318.2M110](/packages/laravel-mcp)[spatie/laravel-health

Monitor the health of a Laravel application

87311.3M149](/packages/spatie-laravel-health)[simplestats-io/laravel-client

Analytics for Laravel. Track visitors, registrations, and payments. Discover which channels actually drive revenue, not just traffic. Server-side, GDPR compliant, ad-blocker proof.

5019.3k](/packages/simplestats-io-laravel-client)

PHPackages © 2026

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