PHPackages                             benclerc/fortinet-fortiosapi - 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. benclerc/fortinet-fortiosapi

ActiveLibrary[API Development](/categories/api)

benclerc/fortinet-fortiosapi
============================

PHP library used for interacting with Fortigate firewall (FortiOS) APIs.

6.4.5(2y ago)53693MITPHPPHP &gt;=7.4.0

Since Jun 6Pushed 2y ago1 watchersCompare

[ Source](https://github.com/benclerc/Fortinet-FortiOSAPI)[ Packagist](https://packagist.org/packages/benclerc/fortinet-fortiosapi)[ Docs](https://github.com/benclerc/Fortinet-FortiOSAPI)[ RSS](/packages/benclerc-fortinet-fortiosapi/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (3)Used By (0)

Fortinet Fortigate configuration API (FortiOS)
==============================================

[](#fortinet-fortigate-configuration-api-fortios)

*This library is automatically generated, if you want support for a newer version, please open an issue.*

PHP library used for interacting with Fortigate firewall (FortiOS) APIs (CMDB (Configuration), Log and Monitor). This library can retrieve, create, update and delete configuration on the firewall.

You can find all supported methods on [Fortinet's developer website](https://fndn.fortinet.net/index.php?/fortiapi/1-fortios/), you will need an account to browse information.

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

[](#table-of-contents)

- [Getting started](#getting-started)
- [Documentation](#documentation)
    - [Config class](#config-class)
        - [Usage](#usage)
        - [Examples](#examples)
    - [Configuration, Log and Monitor classes](#configuration-log-and-monitor-classes)
        - [Usage](#usage)
        - [Examples](#examples-1)
        - [Transactions](#transactions)

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

[](#getting-started)

1. Get [Composer](http://getcomposer.org/).
2. Install the library using composer `composer require benclerc/fortinet-fortiosapi`.
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 `$configConnection = new \Fortinet\FortiOSAPI\Config('123.123.123.123', 'admin', 'password');`.
5. Use the Config object previously created to instanciate the FortiOSAPI object `$firewallConf = new \Fortinet\FortiOSAPI\Configuration($configConnection);`.
6. Start using the library `$staticRoutes = $firewallConf->getAllRouterStatic();`.

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

[](#documentation)

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

### Config class

[](#config-class)

#### Usage

[](#usage)

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

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

Optional parameters :

- Timeout : 5000ms. Use `setTimeout()` to change.
- SSL verify peer option : TRUE. Use `setSSLVerifyPeer()` to change.
- SSL verify host option : 2. Use `setSSLVerifyHost()` to change.
- API version : 2. Use `setAPIVersion()` to change.

#### Examples

[](#examples)

```
// Basic configuration
$configConnection = new \Fortinet\FortiOSAPI\Config('123.123.123.123', 'admin', 'password');

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

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

// Special API version
$configConnection = new \Fortinet\FortiOSAPI\Config('123.123.123.123', 'admin', 'password');
$configConnection->setAPIVersion(1);

// The class logins to the firewall when being instanciated hence the try/catch statement.
// Here I use the class Configuration for the example but it the same for Log and Monitor classes.
try {
	$firewallConf = new \Fortinet\FortiOSAPI\Configuration($configConnection);
} catch (Exception $e) {
	echo('Handle error : '.$e->getMessage());
}
```

### Configuration, Log and Monitor classes

[](#configuration-log-and-monitor-classes)

#### Usage

[](#usage-1)

These classes uses Exception to handle errors, for nominal execution you should instanciate and request methods inside try/catch statements.

#### Examples

[](#examples-1)

```
// Get one particular static route
try {
	$res = $firewallConf->getRouterStatic(1);
	echo('Gateway is : '.$res->results[0]->gateway);
} catch (Exception $e) {
	echo('Handle error : '.$e->getMessage());
}

// Get routes using filters
try {
	// Will return fields dst and status of default gateways
	$res = $firewallConf->getAllRouterStatic(NULL, NULL, NULL, NULL, NULL, NULL, ['dst', 'status'], ['dst==0.0.0.0 0.0.0.0']);
	// For obvious reasons, it would be a charm to use the new PHP 8.0 syntax to call the method :
	// $firewallConf->getAllRouterStatic(format: ['dst', 'status'], filter: ['dst==0.0.0.0 0.0.0.0'])
} catch (Exception $e) {
	echo('Handle error : '.$e->getMessage());
}

// Set a static route
// Define the route
$staticRoute = new stdClass;
$staticRoute->status = 'enable';
$staticRoute->dst = '1.1.1.1 255.255.255.255';
$staticRoute->src = '198.168.1.0 255.255.255.0';
$staticRoute->gateway = '198.168.1.254';
$staticRoute->device = 'lan';
$staticRoute->distance = 20;

// Send the request to the firewall
try {
	$res = $firewallConf->addRouterStatic($staticRoute);

	if ($res->status == 'success') {
		echo('Route added');
	} else {
		echo('Route adding failed');
	}
} catch (Exception $e) {
	echo('Handle error : '.$e->getMessage());
}
```

#### Transactions

[](#transactions)

This library also supports transactions : start a transaction, create, update, delete, and depending on the result commit or abort your changes.

```
// Start transaction
$firewallConf->startTransaction();

// Create many IP objects
$error = FALSE;
for ($i=1; $i < 50; $i++) {
	// Create body object
	$ip = new stdClass;
	$ip->name = 'IP'.$i;
	$ip->type = 'subnet';
	$ip->subnet = '10.1.'.$i.'.0/24';

	// Create object on the firewall
	try {
		$firewallConf->addFirewallAddress($ip);
		echo("[SUCCESS] Created IP ".$ip->name.".\n");
	} catch (Exception $e) {
		echo("[ERROR] Unable to create IP : ".$ip->name.". Details : ".$e->getMessage()."\n");
		$error = TRUE;
	}
}

// Check error
if ($error === FALSE) {
	// No errors, commit
	$firewallConf->commitTransaction();
} else {
	// Errors, abort and rollback
	$firewallConf->abortTransaction();
}
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

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

1077d 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 (38 commits)")[![hhansen06](https://avatars.githubusercontent.com/u/6222378?v=4)](https://github.com/hhansen06 "hhansen06 (5 commits)")[![sin0light](https://avatars.githubusercontent.com/u/30290024?v=4)](https://github.com/sin0light "sin0light (2 commits)")

---

Tags

api-clientfirewallfortigatefortinetfortinet-firewallphp-libraryutm

### Embed Badge

![Health badge](/badges/benclerc-fortinet-fortiosapi/health.svg)

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

###  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)[facebook/php-business-sdk

PHP SDK for Facebook Business

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

PHP wrapper for the Meilisearch API

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

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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