PHPackages                             securenative/securenative-php - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. securenative/securenative-php

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

securenative/securenative-php
=============================

PHP bindings for SecureNative

v1.1.1(5y ago)063MITPHPPHP &gt;=7.2.0CI failing

Since Sep 1Pushed 5y ago4 watchersCompare

[ Source](https://github.com/securenative/securenative-php)[ Packagist](https://packagist.org/packages/securenative/securenative-php)[ Docs](https://github.com/securenative/securenative-php)[ RSS](/packages/securenative-securenative-php/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (6)Dependencies (5)Versions (22)Used By (0)

 [![SecureNative Logo](https://user-images.githubusercontent.com/45174009/77826512-f023ed80-7120-11ea-80e0-58aacde0a84e.png)](https://www.securenative.com)

 **A Cloud-Native Security Monitoring and Protection for Modern Applications**

 [ ![Github Actions](https://github.com/securenative/securenative-php/workflows/CI/badge.svg) ](https://github.com/securenative/securenative-php) [ ![](https://camo.githubusercontent.com/4791fc6762b1e811a2e1f88f7939a0d910a066ad7f8da5618c42d55330c9e642/68747470733a2f2f636f6465636f762e696f2f67682f7365637572656e61746976652f7365637572656e61746976652d7068702f6272616e63682f6d61737465722f67726170682f62616467652e737667) ](https://codecov.io/gh/securenative/securenative-php) [ ![npm version](https://camo.githubusercontent.com/4b3fae6a844d4feac9cf467e75aee6d961a8745c1337c103084fa1b6d03d7f15/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7365637572656e61746976652f7365637572656e61746976652d706870) ](https://packagist.org/packages/securenative/securenative-php)

 [Documentation](https://docs.securenative.com) | [Quick Start](https://docs.securenative.com/quick-start) | [Blog](https://blog.securenative.com) | Chat with us on Slack!

---

[SecureNative](https://www.securenative.com/) performs user monitoring by analyzing user interactions with your application and various factors such as network, devices, locations and access patterns to stop and prevent account takeover attacks.

Install the SDK
---------------

[](#install-the-sdk)

When using Composer run the following command:

```
$ composer require securenative/securenative-php
```

### Add required imports

[](#add-required-imports)

```
require_once __DIR__ . '/vendor/autoload.php';

use SecureNative\sdk\SecureNative;
use SecureNative\sdk\SecureNativeOptions;
use SecureNative\sdk\EventTypes;
use SecureNative\sdk\SecureNativeContext;
```

Initialize the SDK
------------------

[](#initialize-the-sdk)

To get your *API KEY*, login to your SecureNative account and go to project settings page:

### Option 1: Initialize via API\_KEY and SecureNativeOptions

[](#option-1-initialize-via-api_key-and-securenativeoptions)

```
$options = new SecureNativeOptions();
$options->setTimeout(100)
    ->setApiUrl("API URL")
    ->setDisable(false)
    ->setInterval(100)
    ->setAutoSend(true)
    ->setMaxEvents(10)
    ->setLogLevel('fatal');

// Passing `$options` is optional, will use default params
SecureNative::init("[API_KEY]", $options);
```

### Option 2: Initialize via configuration file

[](#option-2-initialize-via-configuration-file)

Attach `securenative.json` file to your root folder:

```
{
  "SECURENATIVE_API_KEY": "YOUR_API_KEY",
  "SECURENATIVE_APP_NAME": "APP_NAME",
  "SECURENATIVE_API_URL": "API_URL",
  "SECURENATIVE_INTERVAL": 1000,
  "SECURENATIVE_MAX_EVENTS": 100,
  "SECURENATIVE_TIMEOUT": 1500,
  "SECURENATIVE_AUTO_SEND": true,
  "SECURENATIVE_DISABLE": false,
  "SECURENATIVE_LOG_LEVEL": "fatal"
}
```

Then, call SDK's `init` function without props (sending props will override JSON configurations).

```
SecureNative::init();
```

### Option 3: Initialize via environment variables

[](#option-3-initialize-via-environment-variables)

Pass desired environment variables (for example):

```
SECURENATIVE_API_KEY=TEST_KEY
SECURENATIVE_API_URL=http://url
SECURENATIVE_INTERVAL=100
SECURENATIVE_MAX_EVENTS=30
SECURENATIVE_TIMEOUT=1500
SECURENATIVE_AUTO_SEND=true
SECURENATIVE_DISABLE=false
SECURENATIVE_LOG_LEVEL=fatal
```

Then, call SDK's `init` function without props (sending props will override JSON configurations).

```
SecureNative::init();
```

Tracking events
---------------

[](#tracking-events)

Once the SDK has been initialized, tracking requests sent through the SDK instance.

```
$clientToken = "[SECURED_CLIENT_TOKEN]";
$headers = (object)["user-agent" => "Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us"];
$ip = "79.179.88.157";
$remoteIp = null;
$url = null;
$method = null;
$body = null;

$ctx = new SecureNativeContext($clientToken, $ip, $remoteIp, $headers, $url, $method, $body);

SecureNative::track(array(
    'event' => EventTypes::LOG_IN,
    'context' => $ctx,
    'userId' => '1234',
    'userTraits' => (object)[
        'name' => 'Your Name',
        'email' => 'name@gmail.com'
    ],
    // Custom properties
    'properties' => (object)[
        "custom_param1" => "CUSTOM_PARAM_VALUE",
        "custom_param2" => true,
        "custom_param3" => 3
    ]
));
```

You can also create request context from request:

```
SecureNative::track(array(
   'event' => EventTypes::LOG_IN,
   'context' => SecureNative::contextFromContext(),
   'userId' => '1234',
   'userTraits' => (object)[
       'name' => 'Your Name',
       'email' => 'name@gmail.com'
   ],
   // Custom properties
   'properties' => (object)[
       "custom_param1" => "CUSTOM_PARAM_VALUE",
       "custom_param2" => true,
       "custom_param3" => 3
   ]
));
```

Verify events
-------------

[](#verify-events)

**Example**

```
$options = new SecureNativeOptions();

$ver = SecureNative::verify(array(
    'event' => EventTypes::VERIFY,
    'userId' => '1234',
    'context' => SecureNative::fromRequest(),
    'userTraits' => (object)[
        'name' => 'Your Name',
        'email' => 'name@gmail.com'
    ]
));

print_r($ver->riskLevel);   // (Low, Medium, High)
print_r($ver->score);       // (0 - Very Low, 1 - Very High)
print_r($ver->triggers);    // (Example: ["TOR", "New IP", "New City"])
```

Webhook signature verification
------------------------------

[](#webhook-signature-verification)

Apply our filter to verify the request is from us, for example:

```
$verified = SecureNative::getMiddleware()->verifySignature();

if ($verified) {
    // Request is trusted (coming from SecureNative)
}
```

Extract proxy headers from cloud providers
------------------------------------------

[](#extract-proxy-headers-from-cloud-providers)

You can specify custom header keys to allow extraction of client ip from different providers. This example demonstrates the usage of proxy headers for ip extraction from Cloudflare.

### Option 1: Using config file

[](#option-1-using-config-file)

```
{
    "SECURENATIVE_API_KEY": "YOUR_API_KEY",
    "SECURENATIVE_PROXY_HEADERS": ["CF-Connecting-IP"]
}
```

Initialize sdk as shown above.

### Options 2: Using ConfigurationBuilder

[](#options-2-using-configurationbuilder)

```
$options = new SecureNativeOptions();
$options->setProxyHeaders(["CF-Connecting-IP"]);

SecureNative::init();
```

Remove PII Data From Headers
----------------------------

[](#remove-pii-data-from-headers)

By default, SecureNative SDK remove any known pii headers from the received request. We also support using custom pii headers and regex matching via configuration, for example:

### Option 1: Using config file

[](#option-1-using-config-file-1)

```
{
    "SECURENATIVE_API_KEY": "YOUR_API_KEY",
    "SECURENATIVE_PII_HEADERS": ["apiKey"]
}
```

Initialize sdk as shown above.

### Options 2: Using ConfigurationBuilder

[](#options-2-using-configurationbuilder-1)

```
$options = new SecureNativeOptions();
$options->setPiiRegexPattern("/http_auth_/i");

SecureNative::init();
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 73.7% 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 ~24 days

Total

20

Last Release

1995d ago

Major Versions

0.0.2 → v1.0.42019-09-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/19981e9512eff2e890320815cedfda6b91c359d2e8085c70c66825adadc12871?d=identicon)[snamit](/maintainers/snamit)

---

Top Contributors

[![AmitBu](https://avatars.githubusercontent.com/u/16814856?v=4)](https://github.com/AmitBu "AmitBu (73 commits)")[![alexivsn](https://avatars.githubusercontent.com/u/45174009?v=4)](https://github.com/alexivsn "alexivsn (14 commits)")[![inbaltako](https://avatars.githubusercontent.com/u/5793759?v=4)](https://github.com/inbaltako "inbaltako (10 commits)")[![MishaKav](https://avatars.githubusercontent.com/u/289035?v=4)](https://github.com/MishaKav "MishaKav (1 commits)")[![nevoalm](https://avatars.githubusercontent.com/u/1942103?v=4)](https://github.com/nevoalm "nevoalm (1 commits)")

---

Tags

phpsdksecurenativesecurity-platformmonitoringsdksecuritysecurenative

### Embed Badge

![Health badge](/badges/securenative-securenative-php/health.svg)

```
[![Health](https://phpackages.com/badges/securenative-securenative-php/health.svg)](https://phpackages.com/packages/securenative-securenative-php)
```

###  Alternatives

[rollbar/rollbar

Monitors errors and exceptions and reports them to Rollbar

33723.7M82](/packages/rollbar-rollbar)[honeybadger-io/honeybadger-php

Honeybadger PHP library

381.5M4](/packages/honeybadger-io-honeybadger-php)[ohdearapp/ohdear-php-sdk

An SDK to easily work with the Oh Dear API

742.6M13](/packages/ohdearapp-ohdear-php-sdk)[gevans/honeybadger

Honeybadger PHP library

387.6k](/packages/gevans-honeybadger)

PHPackages © 2026

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