PHPackages                             benclerc/sophos-xgapi - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. benclerc/sophos-xgapi

ActiveLibrary[HTTP &amp; Networking](/categories/http)

benclerc/sophos-xgapi
=====================

Library used for interacting with Sophos XG firewall API.

1.4(5y ago)6772MITPHPPHP &gt;=7.4.0

Since Mar 4Pushed 3y ago1 watchersCompare

[ Source](https://github.com/benclerc/Sophos-XGAPI)[ Packagist](https://packagist.org/packages/benclerc/sophos-xgapi)[ Docs](https://github.com/benclerc/SophosXGAPI)[ RSS](/packages/benclerc-sophos-xgapi/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (6)Used By (0)

Sophos XGAPI
============

[](#sophos-xgapi)

Sophos XGAPI is a PHP library for requesting Sophos XG firewalls. This library can :

- Retrieve data from the firewall
- Set data on the firewall
- Remove data from the firewall

You can find all supported entities' names on [Sophos website](https://docs.sophos.com/nsg/sophos-firewall/18.0/API/index.html).

Table of contents
-----------------

[](#table-of-contents)

- [Getting started](#getting-started)
- [Documentation](#documentation)
    - [Config class](#config-class)
    - [XGAPI class](#xgapi-class)
        - [get()](#get)
        - [set()](#set)
        - [remove()](#remove)

Getting started
---------------

[](#getting-started)

1. Get [Composer](http://getcomposer.org/).
2. Install the library using composer `composer require benclerc/sophos-xgapi`.
3. Add the following to your application's main PHP file `require 'vendor/autoload.php';`.
4. Instanciate the Config class with the firewall's hostname, username and password `$configFirewall = new \Sophos\Config('123.123.123.123', 'admin', 'password');`.
5. Use the Config object previously created to instanciate the XGAPI object `$firewall = new \Sophos\XGAPI($configFirewall);`.
6. Start using the library `$hosts = $firewall->get(['IPHost']);`.

Documentation
-------------

[](#documentation)

You can find a full documentation [here](https://benclerc.github.io/Sophos-XGAPI/).

### Config class

[](#config-class)

This Config class is used to prepare the mandatory configuration information to instanciate and use the XGAPI class. In the constructor you must pass :

1. The firewall's hostname (FQDN)
2. A valid user's username
3. The valid user's password

Optional parameters :

- CURL timeout : 10000ms. Use `setTimeout()` to change.
- CURL SSL verify peer option : TRUE. Use `setSSLVerifyPeer()` to change.
- CURL SSL verify host option : 2. Use `setSSLVerifyHost()` to change.

Example :

```
// Basic configuration
$configFirewall = new \Sophos\Config('123.123.123.123', 'admin', 'password');

// Configuration for very slow firewalls/long requests
$configFirewall = new \Sophos\Config('123.123.123.123', 'admin', 'password');
$configFirewall->setTimeout(20000);

// Unsecure configuration
$configFirewall = new \Sophos\Config('123.123.123.123', 'admin', 'password');
$configFirewall->setSSLVerifyPeer(FALSE)->setSSLVerifyHost(FALSE);

$firewall = new \Sophos\XGAPI($configFirewall);
```

### XGAPI class

[](#xgapi-class)

#### get()

[](#get)

This method is used to retrieve data from the firewall. You must set which entity/entities you want to retrieve and you can set a filter for each one. Be careful, if you set several filters for the same entity they add up like a 'OR' not an 'AND'. Be careful not all attributes are filterable, see Sophos documentation. Available criterias for filtering :

1. =
2. like
3. !=

Examples :

```
// All IPHost
$entities = ['IPHost'];
// IPHost named 'IP_TEST'
$entities = [
	'IPHost'=>[
		['Name', '=', 'IP_TEST']
	]
];
// All IPHost with 'IP_' in the name OR of type 'Network'
$entities = [
	'IPHost'=>[
		['Name', 'like', 'IP_'],
		['HostType', '=', 'Network']
	]
];
// All IPHost and network interface named LAN
$entities = [
	'IPHost',
	'Interface'=>[
		['Name', '=', 'LAN']
	]
];

try {
	$result = $firewall->get($entites);
} catch (Exception $e) {
	echo('Handle error : '.$e->getMessage());
}
```

#### set()

[](#set)

This method is used to set data on the firewall. You must set all mandatory attributes for each entities you want to add.

Examples :

```
// Add 1 IPv4 hosts
$entities = [
	'IPHost'=> [
		[
			'Name'=>'IP_TEST',
			'IPFamily'=>'IPv4',
			'HostType'=>'IP',
			'HostGroupList'=>[
				'HostGroup'=>'IP-GRP_TEST'
			],
			'IPAddress'=>'10.11.12.13',
			'Subnet'=>'255.255.255.0'
		]
	]
];
// Add 2 IPv4 hosts
$entities = [
	'IPHost'=> [
		[
			'Name'=>'IP_TEST',
			'IPFamily'=>'IPv4',
			'HostType'=>'IP',
			'HostGroupList'=>[
				'HostGroup'=>'IP-GRP_TEST'
			],
			'IPAddress'=>'10.11.12.13',
			'Subnet'=>'255.255.255.0'
		],
		[
			'Name'=>'IP_TEST2',
			'IPFamily'=>'IPv4',
			'HostType'=>'IP',
			'HostGroupList'=>[
				'HostGroup'=>'IP-GRP_TEST'
			],
			'IPAddress'=>'10.11.12.14',
			'Subnet'=>'255.255.255.0'
		]
	]
];
// Add 2 IPv4 hosts and 1 QOS policy
$entities = [
	'IPHost'=> [
		[
			'Name'=>'IP_TEST',
			'IPFamily'=>'IPv4',
			'HostType'=>'IP',
			'HostGroupList'=>[
				'HostGroup'=>'IP-GRP_TEST'
			],
			'IPAddress'=>'10.11.12.13',
			'Subnet'=>'255.255.255.0'
		],
		[
			'Name'=>'IP_TEST2',
			'IPFamily'=>'IPv4',
			'HostType'=>'IP',
			'HostGroupList'=>[
				'HostGroup'=>'IP-GRP_TEST'
			],
			'IPAddress'=>'10.11.12.14',
			'Subnet'=>'255.255.255.0'
		]
	],
	'QoSPolicy'=>[
		[
		'Name'=>'QOS_TEST',
		'PolicyBasedOn'=>'FirewallRule',
		'BandwidthUsageType'=>'Shared',
		'ImplementationOn'=>'Total',
		'PolicyType'=>'Strict',
		'Priority'=>'Normal4',
		'TotalBandwidth'=>'6875'
		]
	]
];

try {
	$result = $firewall->set($entites);
} catch (Exception $e) {
	echo('Handle error : '.$e->getMessage());
}
```

#### remove()

[](#remove)

This method is used to remove data from the firewall. You must set the entities you want to delete as well as the name of the objects you want to delete, you cannot delete on anything else than the object's name.

Examples :

```
// Remove the IPv4 host 'IP_TEST'
$entities = [
	'IPHost'=> [
		'IP_TEST'
	]
];
// Remove the IPv4 hosts 'IP_TEST' and 'IP_TEST2'
$entities = [
	'IPHost'=> [
		'IP_TEST',
		'IP_TEST2'
	]
];
// Remove the IPv4 hosts 'IP_TEST' and 'IP_TEST2' and QOS policy 'QOS_TEST'
$entities = [
	'IPHost'=> [
		'IP_TEST',
		'IP_TEST2'
	],
	'QoSPolicy'=> [
		'QOS_TEST'
	]
];

try {
	$result = $firewall->remove($entites);
} catch (Exception $e) {
	echo('Handle error : '.$e->getMessage());
}
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~1 days

Total

5

Last Release

1942d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3b52a5a1fcfa2dc90b63bb0d58114fe8bae432ede9797ef52cb5579859910b44?d=identicon)[benclerc](/maintainers/benclerc)

---

Top Contributors

[![benclerc](https://avatars.githubusercontent.com/u/79925489?v=4)](https://github.com/benclerc "benclerc (31 commits)")

---

Tags

firewallfirewall-managementlibrarynetworkingphpphp-librarysophossophos-xgutm

### Embed Badge

![Health badge](/badges/benclerc-sophos-xgapi/health.svg)

```
[![Health](https://phpackages.com/badges/benclerc-sophos-xgapi/health.svg)](https://phpackages.com/packages/benclerc-sophos-xgapi)
```

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25126.1M81](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.9M6.8k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k24.3k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87965.9k114](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.4M89](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69127.2k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

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