PHP code example of webkernelai / php-sdk

1. Go to this page and download the library: Download webkernelai/php-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

webkernelai / php-sdk example snippets




use WebKernelAI\SDK\Config;
use WebKernelAI\SDK\Client;

ebkernelai.com/php-sdk)
$config = new Config([
    'site_id'          => 'YOUR_SITE_ID',
    'pairing_secret'   => 'YOUR_PAIRING_SECRET_KEY',
    'api_url'          => 'https://api.webkernelai.com',
    'enable_waf'       => true,
    'enable_headers'   => true,
    'excluded_routes'  => ['/admin', '/backend', '/administrator', '/dashboard'], // Bypass WAF on admin panels
    'whitelisted_ips'  => ['123.456.78.90'], // Optional: whitelist admin/office IPs
]);

// 2. Boot WebKernelAI Engine
// Automatically handles API handshake endpoint (/webkernelai-api), WAF threat filtering, security headers, and dynamic SEO sync
$client = new Client($config);
$client->boot();

// app/Http/Kernel.php
protected $middleware = [
    // ...
    \WebKernelAI\SDK\Laravel\WebKernelAISecurityMiddleware::class,
];

$config['enable_hooks'] = TRUE;
$config['webkernelai_site_id'] = 'your_site_id';
$config['webkernelai_pairing_secret'] = 'your_pairing_secret_key';

// Bypass WAF for your admin panel and whitelist admin IPs:
$config['webkernelai_excluded_routes'] = ['/admin', '/backend', '/dashboard'];
$config['webkernelai_whitelisted_ips'] = ['123.456.78.90'];

$hook['pre_system'] = array(
    'class'    => 'WebKernelAISecurityFilter',
    'function' => 'hook',
    'filename' => 'WebKernelAISecurityFilter.php',
    'filepath' => 'hooks'
);

// app/Config/Filters.php
public array $aliases = [
    // ...
    'webkernelai' => \WebKernelAI\SDK\CodeIgniter\WebKernelAISecurityFilter::class,
];

public array $globals = [
    'before' => [
        'webkernelai',
    ],
];

use WebKernelAI\SDK\Security\Signer;

$secret    = 'your_pairing_secret';
$payload   = json_encode(['action' => 'security_audit', 'site_id' => 123]);
$timestamp = (string) time();
$nonce     = Signer::generateNonce();

// 1. Generate Signature
$signature = Signer::generateSignature($payload, $timestamp, $nonce, $secret);

// 2. Verify Signature (enforces 300-second replay window protection)
$isValid = Signer::verifySignature($payload, $timestamp, $nonce, $signature, $secret, 300);

if (!$isValid) {
    throw new Exception('Invalid signature or expired replay attempt.');
}
bash
composer