Download the PHP package pooshgan/pasarguard-php without Composer

On this page you can find all versions of the php package pooshgan/pasarguard-php. 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 pasarguard-php

PasarGuard PHP SDK

Language / زبان: فارسی

![PHP](https://img.shields.io/badge/PHP-%3E%3D8.1-blue.svg?style=flat-square&logo=php) ![License](https://img.shields.io/badge/License-MIT-green.svg?style=flat-square) ![Packagist](https://img.shields.io/packagist/v/pooshgan/pasarguard-php.svg?style=flat-square) ![Coverage](https://img.shields.io/badge/API_Coverage-100%25-brightgreen.svg?style=flat-square) **A production-ready, strongly-typed PHP SDK for the [PasarGuard Panel](https://github.com/PasarGuard/panel) API.** [Installation](#installation) • [Quick Start](#quick-start) • [Endpoints](#endpoints) • [Examples](#real-world-examples) • [Error Handling](#error-handling) • [Advanced](#advanced-usage)

Table of Contents


Overview

PasarGuard PHP SDK is a fully-typed, ergonomic client library for interacting with the PasarGuard Panel API. It is built on top of GuzzleHTTP and follows modern PHP 8.1+ conventions including strict typing, PSR-4 autoloading, and predictable method signatures.

The SDK covers 100% of the PasarGuard API surface, exposing every endpoint (Users, Nodes, Cores, Admins, Hosts, Groups, Subscriptions, Templates, Settings, System stats, HWID management, and more) through a clean, chainable object-oriented interface. Every method maps 1:1 to an API route, with parameters strongly typed and request payloads normalized to PHP arrays.

Whether you are building a custom dashboard, automating user provisioning, integrating billing, or running a Telegram Mini App backed by PasarGuard, this SDK gives you a stable foundation without the boilerplate of raw HTTP calls.


Features


Requirements

Requirement Version
PHP >= 8.1
GuzzleHTTP ^7.0
ext-json bundled
ext-curl recommended (Guzzle default handler)

The SDK is framework-agnostic: it works equally well inside Laravel, Symfony, Yii, CodeIgniter, CakePHP, plain PHP scripts, or long-running workers (RoadRunner, Swoole, FrankenPHP).


Installation

Install via Composer:

If you don't have Composer yet:

After installation, include the Composer autoloader in your entry-point file:


Quick Start


Architecture

The SDK is intentionally small and follows a layered design:

Key design choices

  1. Single facade. You always work through PasarGuard. No need to instantiate endpoints manually.
  2. Guzzle under the hood. All advanced Guzzle options (proxy, SSL, timeouts, middlewares) are exposed via the optional $guzzleOptions constructor argument.
  3. Predictable signatures. Every mutating method follows (string $identifier, array $data = [], array $query = [], array $headers = []). Every reading method follows (array $query = [], array $headers = []). This means you can guess the signature of any method you have never used.
  4. By-username / by-id variants. Most user- and admin-targeted endpoints ship in three flavours: by username, byUsername(), and byId(). Pick whichever identifier you have on hand.

Endpoints

All endpoint groups are accessible as properties on the PasarGuard facade:

Property Class Base Path
$api->adminRoles Endpoints\AdminRole /api/admin-roles
$api->users Endpoints\User /api/users
$api->hosts Endpoints\Host /api/hosts
$api->groups Endpoints\Group /api/groups
$api->hwids Endpoints\Hwid /api/users/{id}/hwids
$api->setup Endpoints\Setup /api/setup
$api->system Endpoints\System /api
$api->cores Endpoints\Core /api/cores
$api->nodes Endpoints\Node /api
$api->subscriptions Endpoints\Subscription /sub
$api->userTemplates Endpoints\UserTemplate /api/user_templates
$api->admins Endpoints\Admin /api
$api->settings Endpoints\Settings /api/settings
$api->clientTemplates Endpoints\ClientTemplate /api/client_templates
$api->home Endpoints\Home /api

Users

The users group is the largest endpoint. It manages subscribers, their data limits, expirations, ownership, subscriptions, and bulk operations. Every method that targets a single user ships in three variants — by default username slug, getByUsername(), and getById() — so you can use whichever identifier your application holds.

List and search users

Get a single user

Create, update, delete

Enable / Disable

Reset usage & revoke subscription

Ownership & next-plan activation

Usage & metrics

Expired users

Bulk operations

All bulk methods accept an array of identifiers (usernames or ids, depending on the variant) and additional payload data.

Template-based user creation

You can pre-define user templates in the panel and instantiate users from them — great for SaaS-style provisioning.


Admins

The admins group manages resellers and administrators. In addition to the CRUD operations familiar from the users group, admins expose a getToken() flow (for reseller login) and a getMiniAppToken() flow (for Telegram Mini App auth), as well as operations that act on the users owned by an admin.

Authentication

CRUD

List and inspect

Acting on an admin's users

Bulk admin operations


Admin Roles

Role-based access control for admins.


Nodes

Nodes represent the actual proxy servers running your cores. The nodes group covers CRUD, software / core / geofiles updates, reconnection, sync, logs, and stats.


Cores

A "core" is the underlying proxy binary (e.g., Xray, Marzban-node, Sing-box) that a node runs.


Hosts

Hosts are the public-facing addresses / SNI entries users connect to.


Groups

Groups let you bundle users for collective operations.


HWIDs

Hardware-ID locks for client apps that enforce device binding.


Subscriptions

Subscription endpoints are served from /sub by default (configurable via the Client constructor). These are the URLs that end-users put into their client apps.

If your panel exposes subscriptions under a different path (e.g., /custom-sub), pass it to the client once:

Every /sub-prefixed request from Subscription will then automatically use /custom-sub.


User Templates

Reusable recipes for creating users with a pre-configured set of proxies, data limits, expirations, and notes.


Client Templates

Templates that customize what each subscription client (v2rayNG, Streisand, V2RayN, ...) sees — useful for branding, custom configs, or pushing in-app ads.


Settings

Panel-wide settings (subscription path, Telegram bot, captcha, branding, etc.).


System

Server-level stats, inbound info, and worker health — handy for dashboards and uptime monitors.


Setup

One-time setup endpoints for creating / upgrading / deleting the panel owner.


Home

Health-check endpoint — useful for uptime probes and load-balancer checks.


Real-World Examples

1. Provision 100 users from a template

2. Daily cron: disable expired users and email a summary

3. Telegram Mini App: authenticate an admin

4. Custom HTTP layer (proxy + extended timeout)

5. Per-request custom header (e.g., Telegram Mini App auth on a single call)


Error Handling

Every non-2xx response throws a single, predictable exception:

HTTP Status Cause
400 Malformed payload / validation error
401 Missing or invalid bearer token
403 Authenticated but not permitted (insufficient role)
404 Entity (user / node / core / ...) not found
409 Conflict (e.g., username already taken)
422 Semantically invalid request
429 Rate limit hit — back off and retry
5xx Server-side error — retry with exponential backoff

Retry helper example


Advanced Usage

Sharing a single SDK instance across long-running workers

The SDK is stateless per request. You can build one PasarGuard instance at worker bootstrap and reuse it for thousands of jobs:

Injecting custom Guzzle middlewares

Because the SDK never hides Guzzle, you can attach any middleware by passing a pre-built GuzzleClient instance to a custom subclass of Client, or by manipulating the handler stack through guzzleOptions. For most use-cases, the constructor options are enough:

Using multiple panels at once

Non-default subscription path

Sending form params instead of JSON

Most mutating methods send JSON. For the few routes that expect form-encoded bodies (e.g., admin login), the SDK already uses form_params. For custom cases, you can pass a raw Guzzle multipart or form_params option through the headers / query slots — or, more cleanly, extend the endpoint:


API Reference

Client

Parameter Type Description
baseUrl string Panel root URL, e.g. https://panel.example.com. Trailing slash is trimmed.
token string Bearer token used in the Authorization header.
subscriptionPath string Path prefix for subscription endpoints. Defaults to /sub.
guzzleOptions array Any options accepted by GuzzleHttp\Client constructor (proxy, timeout, verify, etc.).

Client::request()

Performs an HTTP request and returns the decoded JSON payload as an array. Throws PasarGuardException on any non-2xx response.

PasarGuard

A facade holding 15 endpoint instances. Construct it with a Client:

Endpoint method signature conventions

Every endpoint method follows one of three canonical shapes:

PasarGuardException


Credits


License

This project is licensed under the MIT License.

Copyright (c) 2026 Kazem Pooshgan


All versions of pasarguard-php with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
guzzlehttp/guzzle Version ^7.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 pooshgan/pasarguard-php contains the following files

Loading the files please wait ...