PHPackages                             cleaniquecoders/kong-admin-api - 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. cleaniquecoders/kong-admin-api

ActiveLibrary[API Development](/categories/api)

cleaniquecoders/kong-admin-api
==============================

A PHP package for seamless interaction with Kong Gateway's Admin API

v1.0.2(1y ago)018[5 PRs](https://github.com/cleaniquecoders/kong-admin-api/pulls)MITPHPPHP ^8.2CI passing

Since Nov 5Pushed 1mo agoCompare

[ Source](https://github.com/cleaniquecoders/kong-admin-api)[ Packagist](https://packagist.org/packages/cleaniquecoders/kong-admin-api)[ Docs](https://github.com/cleaniquecoders/kong-admin-api)[ GitHub Sponsors](https://github.com/cleaniquecoders)[ RSS](/packages/cleaniquecoders-kong-admin-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (5)Versions (9)Used By (0)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2323fe76327203a1b400791d951a9e378c9c8ad916120c81d89c81c62d0f5559/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636c65616e69717565636f646572732f6b6f6e672d61646d696e2d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cleaniquecoders/kong-admin-api) [![Tests](https://camo.githubusercontent.com/1b4856400c88b212b589dd85b3499c9e98d6e0b6c2883b21694887e8bf8472a4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636c65616e69717565636f646572732f6b6f6e672d61646d696e2d6170692f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/cleaniquecoders/kong-admin-api/actions/workflows/run-tests.yml) [![Total Downloads](https://camo.githubusercontent.com/17217a99ac7e661d00dec66ba5dd69bdcb1a46509438c3da512fca673dd19dac/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636c65616e69717565636f646572732f6b6f6e672d61646d696e2d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cleaniquecoders/kong-admin-api)

Kong Admin API
==============

[](#kong-admin-api)

A PHP package for seamless interaction with Kong Gateway's Admin API

Installation
------------

[](#installation)

You can install the package via Composer:

```
composer require cleaniquecoders/kong-admin-api
```

### Setup Kong Gateway API Loopback

[](#setup-kong-gateway-api-loopback)

For initial setup, you need Kong Gateway configured with loopback it's Admin API and enable header based authentication. Following are an example of the setup. These commands will simply create the new consumer, add admin API service, create API key for consumer.

```
#!/bin/bash

echo " 🚀 Create Admin API Service"
curl --request POST \
  --url http://localhost:8001/services \
  --data name=admin-api-service \
  --data url='http://localhost:8001' | jq '.' > admin-api-service.json

echo " 🚀 Create Admin API Route"
curl --request POST \
  --url http://localhost:8001/services/admin-api-service/routes \
  --data 'paths[]=/admin-api' \
  --data name=admin-api-route | jq '.' > admin-api-route.json

echo " 🚀 Enable Key Auth on Admin API Service"
curl --request POST \
  --url http://localhost:8001/services/admin-api-service/plugins \
  --header 'Content-Type: application/json' \
  --header 'accept: application/json' \
  --data '{"name":"key-auth","config":{"key_names":["api-key"],"key_in_query":false}}' | jq '.' > admin-api-key.json

echo " 🚀 Create Admin API Consumer"
curl --request POST \
  --url http://localhost:8001/consumers \
  --header 'Content-Type: application/json' \
  --header 'accept: application/json' \
  --data '{"username":"apim","custom_id":"apim"}' | jq '.' > consumer-apim.json

echo " 🚀 Create APIM API Key"
curl -X POST http://localhost:8001/consumers/apim/key-auth | jq '.' > admin-api-consumer-key.json
```

Usage
-----

[](#usage)

Here are examples of using this package:

### Initialize Configuration

[](#initialize-configuration)

```
use CleaniqueCoders\KongAdminApi\Configuration;

$configuration = new Configuration(
    base: 'http://127.0.0.1:8000',
    uri: 'admin-api',
    apiKey: 'your-api-key',
    keyName: 'api-key'
);
```

### Create Connector and Client

[](#create-connector-and-client)

```
use CleaniqueCoders\KongAdminApi\Client;
use CleaniqueCoders\KongAdminApi\Connector;

$connector = new Connector($configuration);
$client = new Client($connector);
```

### Example: Store a New Service

[](#example-store-a-new-service)

Stores a new service with the specified name and URL.

```
use CleaniqueCoders\KongAdminApi\Enums\Endpoint;
use CleaniqueCoders\KongAdminApi\Request;

$response = $client->send(
    (new Request)
        ->setEndPoint(Endpoint::SERVICES)
        ->store([
            'name' => 'example-service',
            'url' => 'http://example.com'
        ])
);

print_r($response);
```

### Example: Update an Existing Service

[](#example-update-an-existing-service)

Updates an existing service (specified by `identifier`) with new data.

```
$response = $client->send(
    (new Request)
        ->setEndPoint(Endpoint::SERVICES)
        ->update('example-service', [
            'url' => 'http://new-example.com'
        ])
);

print_r($response);
```

### Example: Delete a Service

[](#example-delete-a-service)

Deletes a service specified by the `identifier`.

```
$response = $client->send(
    (new Request)
        ->setEndPoint(Endpoint::SERVICES)
        ->delete('example-service')
);

print_r($response);
```

### Example: Get a Specific Service

[](#example-get-a-specific-service)

Retrieves details for a single service by passing the `identifier`.

```
$response = $client->send(
    (new Request)
        ->setEndPoint(Endpoint::SERVICES)
        ->get('example-service')
);

print_r($response);
```

### Example: Get a List of All Services

[](#example-get-a-list-of-all-services)

Retrieves a list of all services without specifying an identifier.

```
$response = $client->send(
    (new Request)
        ->setEndPoint(Endpoint::SERVICES)
        ->get()
);

print_r($response);
```

### Example: Add a Rate-Limiting Plugin to a Consumer

[](#example-add-a-rate-limiting-plugin-to-a-consumer)

Associates a rate-limiting plugin with a specific consumer, configuring the rate limit to 5 requests per minute.

```
use CleaniqueCoders\KongAdminApi\Enums\Plugin;

$response = $client->send(
    (new Request)
        ->plugin(Plugin::RATE_LIMITING, Endpoint::CONSUMERS, 'consumer-id')
        ->store(['config' => ['minute' => 5]])
);

print_r($response);
```

### Example: Update a CORS Plugin for a Route

[](#example-update-a-cors-plugin-for-a-route)

Updates an existing CORS plugin associated with a specific route, allowing all origins.

```
$response = $client->send(
    (new Request)
        ->plugin(Plugin::CORS, Endpoint::ROUTES, 'route-id', 'plugin-id')
        ->update('plugin-id', ['config' => ['origins' => ['*']]])
);

print_r($response);
```

### Example: Get a JWT Plugin for a Service

[](#example-get-a-jwt-plugin-for-a-service)

Retrieves details of a JWT plugin associated with a specific service.

```
$response = $client->send(
    (new Request)
        ->plugin(Plugin::JWT, Endpoint::SERVICES, 'service-id', 'plugin-id')
        ->get()
);

print_r($response);
```

### Example: Delete an HMAC Authentication Plugin from a Service

[](#example-delete-an-hmac-authentication-plugin-from-a-service)

Deletes an HMAC authentication plugin associated with a specific service.

```
$response = $client->send(
    (new Request)
        ->plugin(Plugin::HMAC_AUTH, Endpoint::SERVICES, 'service-id', 'plugin-id')
        ->delete('plugin-id')
);

print_r($response);
```

References
----------

[](#references)

For more details on available endpoints, parameters, and usage of the Kong Admin API, please refer to the [Kong Admin API documentation](https://docs.konghq.com/gateway/latest/admin-api/).

To explore the plugins available for free and open-source use, visit the [Kong Hub Plugins page](https://docs.konghq.com/hub/?tier=free).

The [`Endpoint`](src/Enums/Endpoint.php) enum in this package reflects the endpoints defined in the OpenAPI specification provided by Kong.

Certainly! Here’s the list of free and open-source plugins available in Kong's free tier, as per the Kong Hub documentation:

### List of Free Tier Plugins for Kong

[](#list-of-free-tier-plugins-for-kong)

Plugin IdentifierEndpointLabelDescription`acl``acls`ACLControl access to services and routes by whitelisting or blacklisting consumers.`bot-detection``bot-detection`Bot DetectionIdentify and block bot traffic based on various techniques and algorithms.`cors``cors`CORSEnable Cross-Origin Resource Sharing (CORS) on a service or route.`ip-restriction``ip-restriction`IP RestrictionAllow or deny access based on the client's IP address.`jwt``jwt`JWTValidate JSON Web Tokens (JWT) for authentication purposes.`key-auth``key-auth`Key AuthenticationAuthenticate users using an API key that consumers include in their requests.`ldap-auth``ldap-auth`LDAP AuthenticationAuthenticate users against an LDAP server.`oauth2``oauth2`OAuth 2.0Add OAuth 2.0 authentication to protect your APIs.`rate-limiting``rate-limiting`Rate LimitingLimit the number of requests a user can make to an API within a defined period.`request-size-limiting``request-size-limiting`Request Size LimitingLimit the size of client request bodies.`request-termination``request-termination`Request TerminationTerminate incoming requests based on certain criteria, such as status code or message.`response-ratelimiting``response-ratelimiting`Response Rate LimitingControl response rates based on defined criteria.`session``session`Session ManagementManage sessions and store session data across multiple requests.`basic-auth``basic-auth`Basic AuthenticationProvide basic authentication (username and password) for consumers.`hmac-auth``hmac-auth`HMAC AuthenticationAuthenticate users using HMAC signature-based authentication.`datadog``datadog`DatadogSend request metrics to Datadog for monitoring and alerting.`prometheus``prometheus`PrometheusExpose metrics in a format that Prometheus can scrape for monitoring.`statsd``statsd`StatsDSend request metrics to a StatsD server for monitoring.`tcp-log``tcp-log`TCP LogLog request data to a TCP server for monitoring or analysis.`udp-log``udp-log`UDP LogLog request data to a UDP server for monitoring or analysis.`file-log``file-log`File LogLog request data to a file for later review.`http-log``http-log`HTTP LogLog request data to an HTTP endpoint for monitoring or analysis.`syslog``syslog`SyslogLog request data to the Syslog service for centralized logging.This list includes each plugin’s **identifier**, **endpoint**, **label**, and a brief **description** of its functionality. These plugins can be used to add various features such as rate limiting, authentication, logging, and monitoring to Kong APIs in the free and open-source tier.

Testing
-------

[](#testing)

To run tests:

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details on how to contribute. See [development](docs/development.md) documentation details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Nasrul Hazim Bin Mohamad](https://github.com/nasrulhazim)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance73

Regular maintenance activity

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

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

Every ~21 days

Total

3

Last Release

508d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b57069d0f4b634f65eccc6e5d5848990e25968d45ec2cf46d626c6a4658f944b?d=identicon)[nasrulhazim.m](/maintainers/nasrulhazim.m)

---

Top Contributors

[![nasrulhazim](https://avatars.githubusercontent.com/u/10341422?v=4)](https://github.com/nasrulhazim "nasrulhazim (45 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (6 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")

---

Tags

apiapi-gatewaykong-adminkong-gatewayphpcleaniquecoderskong-admin-api

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/cleaniquecoders-kong-admin-api/health.svg)

```
[![Health](https://phpackages.com/badges/cleaniquecoders-kong-admin-api/health.svg)](https://phpackages.com/packages/cleaniquecoders-kong-admin-api)
```

###  Alternatives

[skagarwal/google-places-api

Google Places Api

1913.0M8](/packages/skagarwal-google-places-api)[saloonphp/laravel-plugin

The official Laravel plugin for Saloon

765.7M124](/packages/saloonphp-laravel-plugin)[saloonphp/rate-limit-plugin

Handle rate limits beautifully in your Saloon API integrations or SDKs

201.3M43](/packages/saloonphp-rate-limit-plugin)[myoutdeskllc/salesforce-php

salesforce library for php8+

1560.8k](/packages/myoutdeskllc-salesforce-php)[codebar-ag/laravel-docuware

DocuWare integration with Laravel

1221.1k](/packages/codebar-ag-laravel-docuware)[sandorian/moneybird-api-php

Moneybird API client for PHP

127.3k](/packages/sandorian-moneybird-api-php)

PHPackages © 2026

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