hypernic/nawala
最新稳定版本:v1.0.2
Composer 安装命令:
composer require hypernic/nawala
包简介
Hypernic Nawala is a PHP library to check whether a website or domain is blocked in Indonesia.
README 文档
README
A PHP library to check whether a website or domain is blocked in Indonesia.
Requirements
- PHP >= 8.0
curl,jsonintloptional for IDN domains
Installation
composer require hypernic/nawala
Quick Start
index.php:
<?php declare(strict_types=1); header('Content-Type: application/json'); require __DIR__ . '/vendor/autoload.php'; use Hypernic\Nawala; $nawala = new Nawala([ 'timeout' => 10, // seconds 'connect_timeout' => 5, // seconds 'retries' => 1, // light retry for transient errors 'cache' => [ 'enabled' => true ] ]); $result = $nawala->check('example.com'); echo json_encode($result, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
Example output (success, not blocked):
{
"status": true,
"data": {
"domain": "example.com",
"blocked": false
}
}
Example output (success, blocked):
{
"status": true,
"data": {
"domain": "pornhub.com",
"blocked": true
}
}
Example output (invalid input):
{ "status": false, "error": "domain is not valid" }
API
Class: Hypernic\Nawala
__construct(array $config = [])
Config options:
timeout(int, default15): request timeout.connect_timeout(int, default10): connection timeout.retries(int, default1): retry count for transient errors (408, 429, 5xx).
check(string $domain): array
-
Normalizes the domain (lowercase, strips scheme, trims trailing dot).
-
Supports IDN via
intlwhen available. -
Calls the Komdigi endpoint and maps result:
blocked = truewhenStatus === "Ada".
How It Works
-
Data source:
https://trustpositif.komdigi.go.id. -
Flow:
- Normalize domain + IDN handling.
- POST to the public endpoint.
- Pick the most relevant row and determine
blocked.
Note: The upstream service may change without notice. Handle network failures and schema changes in your application.
Testing
This project includes PHPUnit tests.
./vendor/bin/phpunit --bootstrap vendor/autoload.php tests/test.php
Notes
- Subject to Komdigi availability and rate limits.
- Upstream HTML/token/endpoint changes may require library updates.
- Results reflect the status at query time only.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-11